static int stop(struct action_event *event) { if (obtain_instanceid(event, NULL) < 0) { return -1; } service_lock(); switch (transport_state_) { case TRANSPORT_STOPPED: // nothing to change. break; case TRANSPORT_PLAYING: case TRANSPORT_TRANSITIONING: case TRANSPORT_PAUSED_RECORDING: case TRANSPORT_RECORDING: case TRANSPORT_PAUSED_PLAYBACK: output_stop(); change_transport_state(TRANSPORT_STOPPED); break; case TRANSPORT_NO_MEDIA_PRESENT: /* action not allowed in these states - error 701 */ upnp_set_error(event, UPNP_TRANSPORT_E_TRANSITION_NA, "Transition not allowed; allowed=%s", get_var(TRANSPORT_VAR_CUR_TRANSPORT_ACTIONS)); break; } service_unlock(); return 0; }
static void sighup(int s) { if(output_running()) { output_stop(); } else { output_start(); } }
DBG_STATIC int xstop(struct action_event *event) { int rc = 0; if (upnp_obtain_instanceid(event, NULL)) { upnp_set_error(event, UPNP_TRANSPORT_E_INVALID_IID, "ID non-zero invalid"); return -1; } // Check MPD connection if (check_mpd_connection(TRUE) == STATUS_FAIL) return -1; ithread_mutex_lock(&transport_mutex); switch (transport_state) { case TRANSPORT_STOPPED: break; case TRANSPORT_PLAYING: case TRANSPORT_TRANSITIONING: case TRANSPORT_PAUSED_PLAYBACK: if (output_stop()) { upnp_set_error(event, UPNP_TRANSPORT_E_NO_CONTENTS, "Player Stop failed"); rc = -1; } else { transport_state = TRANSPORT_STOPPED; transport_change_var(event, TRANSPORT_VAR_TRANSPORT_STATE, "STOPPED"); } // Set TransportPlaySpeed to '1' break; case TRANSPORT_NO_MEDIA_PRESENT: /* action not allowed in these states - error 701 */ upnp_set_error(event, UPNP_TRANSPORT_E_TRANSITION_NA, "Transition not allowed"); break; } ithread_mutex_unlock(&transport_mutex); return rc; }
void timerPlay(char *uri) { service_lock(); output_stop(); change_transport_state(TRANSPORT_STOPPED); output_set_uri(uri, NULL); replace_var(TRANSPORT_VAR_REL_TIME_POS, kZeroTime); if (output_play(&inform_play_transition_from_output)) { } else { change_transport_state(TRANSPORT_PLAYING); const char *av_uri = get_var(TRANSPORT_VAR_AV_URI); const char *av_meta = get_var(TRANSPORT_VAR_AV_URI_META); replace_current_uri_and_meta(av_uri, av_meta); } service_unlock(); }
static int stop(struct action_event *event) { ENTER(); if (obtain_instanceid(event, NULL)) { return -1; } service_lock(); switch (transport_state_) { case TRANSPORT_STOPPED: // For clients that didn't get it. change_and_notify_transport(TRANSPORT_STOPPED); break; case TRANSPORT_PLAYING: case TRANSPORT_TRANSITIONING: case TRANSPORT_PAUSED_RECORDING: case TRANSPORT_RECORDING: case TRANSPORT_PAUSED_PLAYBACK: output_stop(); change_and_notify_transport(TRANSPORT_STOPPED); // Set TransportPlaySpeed to '1' break; case TRANSPORT_NO_MEDIA_PRESENT: /* action not allowed in these states - error 701 */ upnp_set_error(event, UPNP_TRANSPORT_E_TRANSITION_NA, "Transition not allowed"); break; } service_unlock(); LEAVE(); return 0; }
static void do_down() { output_press(); wait(500); output_stop(); }
static void do_up() { output_vent(); wait(500); output_stop(); }
static void sigusr2(int s) { if(output_running()) { output_stop(); } }
int main(int argc, char *argv[]) { int ret, len; context *pctx; input *in; char buf[512]; int send = 0, backgroud = 0, i; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "tcp")) { send = 1; } if (!strcmp(argv[i], "deamon")) { backgroud = 1; } } if (backgroud) daemon_mode(); pctx = calloc(1, sizeof(context)); if (pctx == NULL) { DBG("error allocating context\n"); return -ENOMEM; } if(signal(SIGINT, fatal_signal) == SIG_ERR) { DBG("could not register signal handler\n"); return -EINVAL; } // create syslog openlog("iMX28-UVC", LOG_PID | LOG_CONS, LOG_USER); // get params from flash ret = params_load(); if (ret < 0) { fprintf(stderr, "load nvram params failed...\n"); } // open manage serial, 1152008N1 ret = serial_init(NULL); if (ret < 0) { fprintf(stderr, "serial_init failed\n"); free(pctx); closelog(); return -1; } // register input video stream ret = input_init(pctx, UVCDEV); if (ret < 0) { fprintf(stderr, "input_init failed, exit\n"); goto exit; } if (send) { // register output video stream ret = output_init("192.168.0.99", 5500); // tcp if (ret < 0 ) { goto exit; } } ret = input_run(pctx); if (ret < 0) { goto exit; } if (send) ret = output_run(pctx->in); in = pctx->in; while (!stop && in) { /* save_jpeg(in->buf, in->size); */ /* allow others to access the global buffer again */ /* sys_if_test(); */ len = recv_packet(buf, sizeof(buf)); if (len > 0) { hex_dump("SP0 RECV:", buf, len); packet_parse(pctx, buf, len); } } /* wait for signals */ pause(); if (send) output_stop(); exit: if (pctx->in->buf) free(pctx->in->buf); free(pctx); closelog(); serial_exit(); DBG("%s:Exit\n", __func__); return 0; }