stream2file_error_msg_t stop_recording(void) { if (exit_flag == STREAM2FILE_STATUS_RUNNING) { CMovieInfo mi; MI_MOVIE_INFO movieinfo; mi.clearMovieInfo(&movieinfo); time(&record_end_time); printf("record time: %lu \n",record_end_time-record_start_time); //load MovieInfo and set record time movieinfo.file.Name = myfilename; movieinfo.file.Name += ".ts"; mi.loadMovieInfo(&movieinfo); movieinfo.rec_length += record_end_time - record_start_time; mi.saveMovieInfo(movieinfo); /* reset record_start_time, so that we know the recording was not aborted abnormally */ record_start_time = 0; exit_flag = STREAM2FILE_STATUS_IDLE; return STREAM2FILE_OK; } else { record_start_time = 0; return STREAM2FILE_RECORDING_THREADS_FAILED; } }
void CMovieCut::save_info(MI_MOVIE_INFO * minfo, char * dpart, off64_t spos, off64_t secsize) { CMovieInfo cmovie; MI_MOVIE_INFO ninfo = *minfo; ninfo.file.Name = dpart; ninfo.file.Size = spos; ninfo.length = spos/secsize/60; ninfo.bookmarks.end = 0; ninfo.bookmarks.start = 0; ninfo.bookmarks.lastPlayStop = 0; for (int book_nr = 0; book_nr < MI_MOVIE_BOOK_USER_MAX; book_nr++) { if (ninfo.bookmarks.user[book_nr].pos != 0 && ninfo.bookmarks.user[book_nr].length > 0) { ninfo.bookmarks.user[book_nr].pos = 0; ninfo.bookmarks.user[book_nr].length = 0; } } cmovie.saveMovieInfo(ninfo); WriteHeader(ninfo.file.Name.c_str(), spos/secsize*1000); reset_atime(dpart, minfo->file.Time); }
bool CMovieCut::truncateMovie(MI_MOVIE_INFO * minfo) { off64_t secsize = getSecondSize(minfo); if (minfo->bookmarks.end == 0 || secsize == 0) return false; off64_t newsize = secsize * minfo->bookmarks.end; printf("CMovieCut::%s: [%s] truncate to %d sec, new size %" PRId64 "\n", __func__, minfo->file.Name.c_str(), minfo->bookmarks.end, newsize); if (truncate(minfo->file.Name.c_str(), newsize)) { perror(minfo->file.Name.c_str()); return false; } minfo->file.Size = newsize; minfo->length = minfo->bookmarks.end/60; minfo->bookmarks.end = 0; reset_atime(minfo->file.Name.c_str(), minfo->file.Time); CMovieInfo cmovie; cmovie.saveMovieInfo(*minfo); WriteHeader(minfo->file.Name.c_str(), newsize/secsize*1000); return true; }
bool cYTCache::download(MI_MOVIE_INFO *mi) { std::string file = getName(mi); std::string xml = getName(mi, "xml"); if (!access(file, R_OK) && !access(xml, R_OK)) { fprintf(stderr, "%s: %s already present and valid\n", __func__, file.c_str()); return true; } FILE * fp = fopen(file.c_str(), "wb"); if (!fp) { perror(file.c_str()); return false; } CURL *curl = curl_easy_init(); if (!curl) { fclose(fp); return false; } curl_easy_setopt(curl, CURLOPT_URL, mi->file.Url.c_str()); curl_easy_setopt(curl, CURLOPT_FILE, fp); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, URL_TIMEOUT); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, cYTCache::curlProgress); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); char cerror[CURL_ERROR_SIZE]; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, cerror); if(!g_settings.softupdate_proxyserver.empty()) { curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); if(!g_settings.softupdate_proxyusername.empty()) { std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str()); } } dltotal = 0; dlnow = 0; dlstart = time(NULL); fprintf (stderr, "downloading %s to %s\n", mi->file.Url.c_str(), file.c_str()); CURLcode res = curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(fp); if (res) { fprintf (stderr, "downloading %s to %s failed: %s\n", mi->file.Url.c_str(), file.c_str(), cerror); unlink(file.c_str()); return false; } CMovieInfo cMovieInfo; CFile File; File.Name = xml; cMovieInfo.saveMovieInfo(*mi, &File); std::string thumbnail_dst = getName(mi, "jpg"); CFileHelpers fh; fh.copyFile(mi->tfile.c_str(), thumbnail_dst.c_str(), 0644); return true; }
std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const t_channel_id channel_id, const event_id_t epgid, const time_t epg_time) { std::string extMessage; CMovieInfo cMovieInfo; MI_MOVIE_INFO movieInfo; std::string info1, info2; cMovieInfo.clearMovieInfo(&movieInfo); CZapitClient::responseGetPIDs pids; g_Zapit->getPIDS (pids); CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); std::string tmpstring = g_Zapit->getChannelName(channel_id); if (tmpstring.empty()) movieInfo.epgChannel = "unknown"; else movieInfo.epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); tmpstring = "not available"; if (epgid != 0) { //#define SHORT_EPG #ifdef SHORT_EPG CSectionsdClient sdc; CShortEPGData epgdata; if (sdc.getEPGidShort(epgid, &epgdata)) { #warning fixme sectionsd should deliver data in UTF-8 format tmpstring = Latin1_to_UTF8(epgdata.title); info1 = Latin1_to_UTF8(epgdata.info1); info2 = Latin1_to_UTF8(epgdata.info2); } #else CSectionsdClient sdc; CEPGData epgdata; if (sdc.getEPGid(epgid, epg_time,&epgdata)) { #warning fixme sectionsd should deliver data in UTF-8 format tmpstring = Latin1_to_UTF8(epgdata.title); info1 = Latin1_to_UTF8(epgdata.info1); info2 = Latin1_to_UTF8(epgdata.info2); movieInfo.parentalLockAge = epgdata.fsk; if(epgdata.contentClassification.size() > 0 ) movieInfo.genreMajor = epgdata.contentClassification[0]; movieInfo.length = epgdata.epg_times.dauer / 60; printf("fsk:%d, Genre:%d, Dauer: %d\r\n",movieInfo.parentalLockAge,movieInfo.genreMajor,movieInfo.length); } #endif } movieInfo.epgTitle = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); movieInfo.epgId = channel_id; movieInfo.epgInfo1 = ZapitTools::UTF8_to_UTF8XML(info1.c_str()); movieInfo.epgInfo2 = ZapitTools::UTF8_to_UTF8XML(info2.c_str()); movieInfo.epgEpgId = epgid ; movieInfo.epgMode = g_Zapit->getMode(); movieInfo.epgVideoPid = si.vpid; EPG_AUDIO_PIDS audio_pids; // super hack :-), der einfachste weg an die apid descriptions ranzukommen g_RemoteControl->current_PIDs = pids; g_RemoteControl->processAPIDnames(); for(unsigned int i= 0; i< pids.APIDs.size(); i++) { audio_pids.epgAudioPid = pids.APIDs[i].pid; audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); movieInfo.audioPids.push_back(audio_pids); } movieInfo.epgVTXPID = si.vtxtpid; cMovieInfo.encodeMovieInfoXml(&extMessage,movieInfo); movieInfo.audioPids.clear(); return extMessage; }
std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const t_channel_id channel_id, const event_id_t epgid, const time_t epg_time, const std::string& epgTitle, unsigned char apids, const bool save_vtxt_pid, const bool save_sub_pids) { std::string extMessage; CMovieInfo cMovieInfo; MI_MOVIE_INFO movieInfo; std::string info1, info2; event_id_t epg_id = epgid; cMovieInfo.clearMovieInfo(&movieInfo); CZapitClient::responseGetPIDs pids; g_Zapit->getPIDS (pids); CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); std::string tmpstring = g_Zapit->getChannelName(channel_id); if (tmpstring.empty()) movieInfo.epgChannel = "unknown"; else movieInfo.epgChannel = tmpstring; tmpstring = (epgTitle.empty()) ? "not available" : Latin1_to_UTF8(epgTitle); if (epg_id != 0) { //#define SHORT_EPG #ifdef SHORT_EPG CShortEPGData epgdata; if (g_Sectionsd->getEPGidShort(epg_id, &epgdata)) { #warning fixme sectionsd should deliver data in UTF-8 format tmpstring = Latin1_to_UTF8(epgdata.title); info1 = Latin1_to_UTF8(epgdata.info1); info2 = Latin1_to_UTF8(epgdata.info2); } #else CEPGData epgdata; bool has_epgdata = g_Sectionsd->getEPGid(epg_id, epg_time, &epgdata); if (!has_epgdata) { has_epgdata = g_Sectionsd->getActualEPGServiceKey(channel_id, &epgdata); if (has_epgdata && !epgTitle.empty() && epgTitle != epgdata.title) has_epgdata = false; if (has_epgdata) epg_id = epgdata.eventID; } if (has_epgdata) { #warning fixme sectionsd should deliver data in UTF-8 format tmpstring = Latin1_to_UTF8(epgdata.title); info1 = Latin1_to_UTF8(epgdata.info1); info2 = Latin1_to_UTF8(epgdata.info2); movieInfo.parentalLockAge = epgdata.fsk; if (!epgdata.contentClassification.empty()) movieInfo.genreMajor = epgdata.contentClassification[0]; movieInfo.length = epgdata.epg_times.dauer / 60; printf("fsk:%d, Genre:%d, Dauer: %d\r\n",movieInfo.parentalLockAge,movieInfo.genreMajor,movieInfo.length); } #endif } movieInfo.epgTitle = tmpstring; movieInfo.epgId = channel_id; movieInfo.epgInfo1 = info1; movieInfo.epgInfo2 = info2; movieInfo.epgEpgId = epg_id; movieInfo.epgMode = g_Zapit->getMode(); movieInfo.epgVideoPid = si.vpid; EPG_AUDIO_PIDS audio_pids; // super hack :-), der einfachste weg an die apid descriptions ranzukommen g_RemoteControl->current_EPGid = epg_id; g_RemoteControl->current_PIDs = pids; g_RemoteControl->processAPIDnames(); APIDList apid_list; getAPIDs(apids,apid_list); for(APIDList::iterator it = apid_list.begin(); it != apid_list.end(); ++it) { audio_pids.epgAudioPid = it->apid; audio_pids.epgAudioPidName = g_RemoteControl->current_PIDs.APIDs[it->index].desc; movieInfo.audioPids.push_back(audio_pids); } if (save_vtxt_pid) movieInfo.epgVTXPID = si.vtxtpid; if (save_sub_pids) { SUB_PIDS sub_pids; for (unsigned int i = 0; i < pids.SubPIDs.size(); i++) { sub_pids.subPid = pids.SubPIDs[i].pid; sub_pids.subPage = pids.SubPIDs[i].composition_page; sub_pids.subName = getISO639Description(pids.SubPIDs[i].desc); movieInfo.subPids.push_back(sub_pids); } } cMovieInfo.encodeMovieInfoXml(&extMessage,movieInfo); return extMessage; }