/* * cmyth_recorder_dup(cmyth_recorder_t old) * * Scope: PUBLIC * * Description * * Copy a recorder structure and return the copy * * Return Value: * * Success: A non-NULL cmyth_recorder_t (this type is a pointer) * * Failure: A NULL cmyth_recorder_t */ cmyth_recorder_t cmyth_recorder_dup(cmyth_recorder_t old) { cmyth_recorder_t ret = cmyth_recorder_create(); if (ret == NULL) { return NULL; } ret->rec_have_stream = old->rec_have_stream; ret->rec_id = old->rec_id; ret->rec_server = ref_hold(old->rec_server); ret->rec_port = old->rec_port; ret->rec_ring = ref_hold(old->rec_ring); ret->rec_conn = ref_hold(old->rec_conn); ret->rec_connected = old->rec_connected; ret->rec_chanlist = ref_hold(old->rec_chanlist); ret->rec_chain = ref_hold(old->rec_chain); return ret; }
/* * cmyth_recorder_dup() * * Scope: PUBLIC * * Description * * Copy a recorder structure and return the copy * * Return Value: * * Success: A non-NULL cmyth_recorder_t (this type is a pointer) * * Failure: A NULL cmyth_recorder_t */ cmyth_recorder_t cmyth_recorder_dup(cmyth_recorder_t old) { cmyth_recorder_t ret = cmyth_recorder_create(); if (ret == NULL) { return NULL; } ret->rec_have_stream = old->rec_have_stream; ret->rec_id = old->rec_id; ret->rec_server = ref_hold(old->rec_server); ret->rec_port = old->rec_port; ret->rec_ring = ref_hold(old->rec_ring); ret->rec_conn = ref_hold(old->rec_conn); ret->rec_framerate = old->rec_framerate; ret->rec_livetv_chain = ref_hold(old->rec_livetv_chain); ret->rec_livetv_file = ref_hold(old->rec_livetv_file); return ret; }
/* * cmyth_conn_get_recorder_from_num(cmyth_conn_t control, * cmyth_recorder_num_t num, * cmyth_recorder_t rec) * * Scope: PUBLIC * * Description * * Obtain a recorder from a connection by its recorder number. The * recorder structure created by this describes how to set up a data * connection and play media streamed from a particular back-end recorder. * * This fills out the recorder structure specified by 'rec'. * * Return Value: * * Success: 0 for not complete, 1 for complete * * Failure: -(errno) */ cmyth_recorder_t cmyth_conn_get_recorder_from_num(cmyth_conn_t conn, int id) { int err, count; int r; long port; char msg[256]; char reply[256]; cmyth_recorder_t rec = NULL; if (!conn) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: no connection\n", __FUNCTION__); return NULL; } pthread_mutex_lock(&mutex); if ((rec=cmyth_recorder_create()) == NULL) goto fail; snprintf(msg, sizeof(msg), "GET_RECORDER_FROM_NUM[]:[]%d", id); if ((err = cmyth_send_message(conn, msg)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_send_message() failed (%d)\n", __FUNCTION__, err); goto fail; } count = cmyth_rcv_length(conn); if (count < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_length() failed (%d)\n", __FUNCTION__, count); goto fail; } if ((r=cmyth_rcv_string(conn, &err, reply, sizeof(reply)-1, count)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_string() failed (%d)\n", __FUNCTION__, r); goto fail; } count -= r; if ((r=cmyth_rcv_long(conn, &err, &port, count)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_rcv_long() failed (%d)\n", __FUNCTION__, r); goto fail; } if (port == -1) goto fail; rec->rec_id = id; rec->rec_server = ref_strdup(reply); rec->rec_port = port; if (cmyth_conn_connect_recorder(rec, conn->conn_buflen, conn->conn_tcp_rcvbuf) < 0) goto fail; pthread_mutex_unlock(&mutex); return rec; fail: if (rec) ref_release(rec); pthread_mutex_unlock(&mutex); return NULL; }