int cmyth_livetv_set_channel(cmyth_recorder_t rec, char *name) { int rc = -1; if (!rec || !rec->rec_connected) { return -1; } if(rec->rec_conn->conn_version >= 26) { cmyth_recorder_pause(rec); if (cmyth_recorder_set_channel(rec, name) < 0) { return -1; } rc = cmyth_livetv_wait(rec); if (rc == 0) { cmyth_chain_switch_last(rec->rec_chain); } } else { /* XXX: ringbuf code? */ } return rc; }
cmyth_recorder_t cmyth_spawn_live_tv(cmyth_recorder_t rec, unsigned buflen, int tcp_rcvbuf, void (*prog_update_callback)(cmyth_proginfo_t), char ** err, char* channame) { cmyth_recorder_t rtrn = NULL; int i; //printf("** SSDEBUG: version is %ld\n", rec->rec_conn->conn_version); if(rec->rec_conn->conn_version >= 26) { if (cmyth_recorder_spawn_chain_livetv(rec, channame) != 0) { *err = "Spawn livetv failed."; goto err; } if ((rtrn = cmyth_livetv_chain_setup(rec, tcp_rcvbuf, prog_update_callback)) == NULL) { *err = "Failed to setup livetv."; goto err; } for(i=0; i<20; i++) { if(cmyth_recorder_is_recording(rtrn) != 1) sleep(1); else break; } } else { if ((rtrn = cmyth_ringbuf_setup(rec)) == NULL) { *err = "Failed to setup ringbuffer."; goto err; } if (cmyth_conn_connect_ring(rtrn, buflen, tcp_rcvbuf) != 0) { *err = "Cannot connect to mythtv ringbuffer."; goto err; } if (cmyth_recorder_spawn_livetv(rtrn) != 0) { *err = "Spawn livetv failed."; goto err; } } if(rtrn->rec_conn->conn_version < 34 && channame) { if (cmyth_recorder_pause(rtrn) != 0) { *err = "Failed to pause recorder to change channel"; goto err; } if (cmyth_recorder_set_channel(rtrn, channame) != 0) { *err = "Failed to change channel on recorder"; goto err; } } err: return rtrn; }