void GPAC_MediaRenderer::SetDuration(Double duration, Bool can_seek) { char szVal[100]; format_time_string(szVal, duration); m_Duration = duration; m_pAVService->SetStateVariable("CurrentTrackDuration", szVal); }
void GPAC_MediaRenderer::SetTime(Double time) { char szVal[100]; format_time_string(szVal, time); m_Time = time; m_pAVService->SetStateVariable("RelativeTimePosition", szVal); m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal); }
/* Function: StopwatchDisplay() * Date: SRE, Fri Nov 26 15:14:12 1999 [St. Louis] * Modified to return the string (wilm) * * Purpose: Return a usage summary line from a *stopped* * stopwatch (the times will reflect the last * time StopwatchStop() was called.) * * For s = "CPU Time: " an example output line is: * CPU Time: 142.55u 7.17s 149.72 Elapsed: 00:02:35.00 * * Args: out - already allocated buffer to write to * w - a (recently stopped) stopwatch * */ void StopwatchDisplay(char *out, Stopwatch_t *w) { char buf[128]; /* (safely holds up to 10^14 years) */ sprintf(out, "CPU Time: "); format_time_string(buf, w->user+w->sys, 1); #ifdef SRE_STRICT_ANSI sprintf(out, "%.2fu %s ", w->user, buf); #else sprintf(out, "%.2fu %.2fs %s ", w->user, w->sys, buf); #endif format_time_string(out, w->elapsed, 0); sprintf(out, "Elapsed: %s\n", buf); }
/* Function: esl_stopwatch_Display() * * Purpose: Output a usage summary line from a stopped * stopwatch, showing elapsed, cpu, and system time * between the last calls to * <esl_stopwatch_Start()> and <esl_stopwatch_Stop()>. * * The string <prefix> will be prepended to the output * line. Use <""> to prepend nothing. If <prefix> is NULL, * a default <"CPU Time: "> prefix is used. * * For <prefix> = <"CPU Time: "> an example output line is:\\ * <CPU Time: 142.55u 7.17s 00:02:29.72 Elapsed: 00:02:35> * * Args: fp - output stream * w - stopped stopwatch * prefix - output line prefix ("" for nothing) * * Returns: <eslOK> on success. * * Throws: <eslEWRITE> on any system write error, such as filled disk. */ int esl_stopwatch_Display(FILE *fp, ESL_STOPWATCH *w, char *prefix) { char buf[128]; /* (safely holds up to 10^14 years; I'll be dead by then) */ if (prefix == NULL) { if (fputs("CPU Time: ", fp) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "stopwatch display write failed"); } else { if (fputs(prefix, fp) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "stopwatch display write failed"); } format_time_string(buf, w->user+w->sys, TRUE); #ifdef HAVE_TIMES if (fprintf(fp, "%.2fu %.2fs %s ", w->user, w->sys, buf) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "stopwatch display write failed"); #else if (fprintf(fp, "%.2fu %s ", w->user, buf) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "stopwatch display write failed"); #endif format_time_string(buf, w->elapsed, TRUE); if (fprintf(fp, "Elapsed: %s\n", buf) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "stopwatch display write failed"); return eslOK; }
/* Function: esl_stopwatch_Display() * Incept: SRE, Sat Feb 25 10:51:09 2006 [St. Louis] * * Purpose: Output a usage summary line from a stopped * stopwatch, showing elapsed, cpu, and system time * between the last calls to * <esl_stopwatch_Start()> and <esl_stopwatch_Stop()>. * * The string <prefix> will be prepended to the output * line. Use <""> to prepend nothing. If <prefix> is NULL, * a default <"CPU Time: "> prefix is used. * * For <prefix> = <"CPU Time: "> an example output line is:\\ * <CPU Time: 142.55u 7.17s 00:02:29.72 Elapsed: 00:02:35> * * Args: fp - output stream * w - stopped stopwatch * prefix - output line prefix ("" for nothing) * * Returns: <eslOK> on success. */ int esl_stopwatch_Display(FILE *fp, ESL_STOPWATCH *w, char *prefix) { char buf[128]; /* (safely holds up to 10^14 years) */ if (prefix == NULL) fputs("CPU Time: ", fp); else fputs(prefix, fp); format_time_string(buf, w->user+w->sys, TRUE); #ifdef HAVE_TIMES fprintf(fp, "%.2fu %.2fs %s ", w->user, w->sys, buf); #else fprintf(fp, "%.2fu %s ", w->user, buf); #endif format_time_string(buf, w->elapsed, 0); fprintf(fp, "Elapsed: %s\n", buf); return eslOK; }
NPT_Result GPAC_MediaRenderer::OnAction(PLT_ActionReference& action, const PLT_HttpRequestContext& context) { NPT_COMPILER_UNUSED(context); /* parse the action name */ NPT_String name = action->GetActionDesc().GetName(); m_ip_src = context.GetRemoteAddress().GetIpAddress().ToString(); /* Is it a ConnectionManager Service Action ? */ if (name.Compare("GetCurrentConnectionIDs", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetProtocolInfo", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetCurrentConnectionInfo", true) == 0) { return OnGetCurrentConnectionInfo(action); } if (name.Compare("StopForMigration", true) == 0) { NPT_String res = m_pUPnP->OnMigrate(); m_pMigrationService->SetStateVariable("MigrationStatus", "OK"); m_pMigrationService->SetStateVariable("MigrationMetaData", res); if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } /* Is it a AVTransport Service Action ? */ // since all actions take an instance ID and we only support 1 instance // verify that the Instance ID is 0 and return an error here now if not NPT_String serviceType = action->GetActionDesc().GetService()->GetServiceType(); if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) { if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) { action->SetError(802,"Not valid InstanceID."); return NPT_FAILURE; } } if (name.Compare("GetCurrentTransportActions", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetDeviceCapabilities", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetMediaInfo", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetPositionInfo", true) == 0) { if (m_pUPnP->m_pTerm->root_scene) { char szVal[100]; m_pAVService->SetStateVariable("CurrentTrack", "0"); format_time_string(szVal, m_Duration); m_pAVService->SetStateVariable("CurrentTrackDuration", szVal); m_pAVService->SetStateVariable("CurrentTrackMetadata", ""); m_pAVService->SetStateVariable("CurrentTrackURI", ""); format_time_string(szVal, m_Time); m_pAVService->SetStateVariable("RelativeTimePosition", szVal); m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal); m_pAVService->SetStateVariable("RelativeCounterPosition", "2147483647"); // means NOT_IMPLEMENTED m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED } else { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } } return NPT_SUCCESS; } if (name.Compare("GetTransportInfo", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("GetTransportSettings", true) == 0) { if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { return NPT_FAILURE; } return NPT_SUCCESS; } if (name.Compare("Next", true) == 0) { return OnNext(action); } if (name.Compare("Pause", true) == 0) { return OnPause(action); } if (name.Compare("Play", true) == 0) { return OnPlay(action); } if (name.Compare("Previous", true) == 0) { return OnPrevious(action); } if (name.Compare("Seek", true) == 0) { return OnSeek(action); } if (name.Compare("Stop", true) == 0) { return OnStop(action); } if (name.Compare("SetAVTransportURI", true) == 0) { return OnSetAVTransportURI(action); } if (name.Compare("SetPlayMode", true) == 0) { return OnSetPlayMode(action); } /* Is it a RendererControl Service Action ? */ if (serviceType.Compare("urn:schemas-upnp-org:service:RenderingControl:1", true) == 0) { /* we only support master channel */ if (NPT_FAILED(action->VerifyArgumentValue("Channel", "Master"))) { action->SetError(402,"Invalid Args."); return NPT_FAILURE; } } if (name.Compare("GetVolume", true) == 0) { NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); return NPT_SUCCESS; } if (name.Compare("GetMute", true) == 0) { NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); return NPT_SUCCESS; } if (name.Compare("SetVolume", true) == 0) { return OnSetVolume(action); } if (name.Compare("SetMute", true) == 0) { return OnSetMute(action); } action->SetError(401,"No Such Action."); return NPT_FAILURE; }
/* * Logs info from /dev/event_log_dev into file */ int main(int argc, const char * argv[]) { double reference_time = 0; // Create log directory struct stat info; if (stat(LOG_DIR, &info) != 0) { if (mkdir(LOG_DIR, 0777) < 0) { perror("ERROR mkdir log directory"); exit(EXIT_FAILURE); } printf("Created log dir: " LOG_DIR "\n"); } // Create log file char eventdevice_log_filename[FILENAME_SIZE] = LOG_DIR "/log_"; int skip = strlen(eventdevice_log_filename); int rc = format_time_string(&eventdevice_log_filename[skip], FILENAME_SIZE, skip); sprintf(&eventdevice_log_filename[skip+rc], "_eventdevice.log"); FILE * edfp = fopen(eventdevice_log_filename,"w"); if (edfp == NULL) { perror("ERROR creating eventdevice log"); exit(EXIT_FAILURE); } printf("Created eventdevice log file: %s\n", eventdevice_log_filename); // Write log header fprintf(edfp, "#Name\t#Open-time\t#PID\t#Latency\n"); fflush(edfp); // Open dev int dlfd = open(DEV_LOG, O_RDWR); if (dlfd < 0) { perror("ERROR opening event_log_dev"); exit(EXIT_FAILURE); } int ndevices = 0; int flag = 0; unsigned char minors[MAX_INPUT_DEVICE]; while (ndevices == 0) { ndevices = get_device(dlfd, minors); if (ndevices < 0) { perror("ERROR get_device"); exit(EXIT_FAILURE); } if (flag == 0) { printf("Wait till gps opens for reading\n"); flag = 1; } } printf("Devices found: %d\n", ndevices); while (1) { //fprintf(edfp, "DEVICE_NAME\tOPEN_TIME\tPID\tLATENCY"); int dev; ndevices = 0; // NOTE: bug in ioctl LGETDEVS code that always // increases dev and never decreases so we only // look at dev 0 or code will cause kernel panic for (dev = 0; dev <= ndevices; dev++) { struct user_event_log log; if (set_device_info(dlfd, dev, minors, &log) < 0) { perror("ERROR set_device_info"); continue; } int i; for (i=0; i<log.ncount; i++) { fprintf(edfp, "%s \t %ld.%06ld \t %d \t %ld.%06ld \n", log.name, log.dev_opened_time.tv_sec, log.dev_opened_time.tv_usec, log.event_consumed[i].pid, log.avg.tv_sec, log.avg.tv_usec); } fflush(edfp); // Not really sure why python module returns inside loop? } sleep(SLEEP_SEC); } }