pa_socket_client *sc;
int fd;
+
pa_raop_client_cb_t callback;
void* userdata;
+ pa_raop_client_closed_cb_t closed_callback;
+ void* closed_userdata;
uint8_t *buffer;
uint32_t buffer_length;
case STATE_SET_PARAMETER:
case STATE_FLUSH:
break;
+ case STATE_DISCONNECTED:
+ pa_assert(c->closed_callback);
+ pa_log_debug("RTSP channel closed");
+ if (c->fd > 0) {
+ pa_close(c->fd);
+ c->fd = -1;
+ }
+ if (c->sc) {
+ pa_socket_client_unref(c->sc);
+ c->sc = NULL;
+ }
+ c->closed_callback(c->closed_userdata);
+ break;
}
}
c->buffer = pa_xrealloc(c->buffer, bufmax);
c->buffer_length = bufmax;
- pa_log_debug("Creating new memblock");
c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
}
c->memchunk.index = 0;
c->callback = callback;
c->userdata = userdata;
}
+
+void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata)
+{
+ pa_assert(c);
+
+ c->closed_callback = callback;
+ c->closed_userdata = userdata;
+}
typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);
+typedef void (*pa_raop_client_closed_cb_t)(void *userdata);
+void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata);
+
#endif
pa_assert(c);
pa_assert(c->response_headers);
+ pa_assert(c->callback);
/* Deal with a SETUP response */
if (STATE_SETUP == c->state) {
}
/* Call our callback */
- if (c->callback)
- c->callback(c, c->state, c->response_headers, c->userdata);
+ c->callback(c, c->state, c->response_headers, c->userdata);
pa_headerlist_free(c->response_headers);
c->response_headers = NULL;
pa_rtsp_client *c = userdata;
pa_assert(line);
pa_assert(c);
+ pa_assert(c->callback);
if (!s) {
- pa_log_warn("Connection closed");
pa_ioline_unref(c->ioline);
c->ioline = NULL;
pa_rtsp_disconnect(c);
+ c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
return;
}
STATE_RECORD,
STATE_TEARDOWN,
STATE_SET_PARAMETER,
- STATE_FLUSH
+ STATE_FLUSH,
+ STATE_DISCONNECTED
} pa_rtsp_state;
typedef void (*pa_rtsp_cb_t)(pa_rtsp_client *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);