DTC::LiveStreamInfo *Content::AddRecordingLiveStream( int nChanId, const QDateTime &dtStartTime, int nMaxSegments, int nWidth, int nHeight, int nBitrate, int nAudioBitrate, int nSampleRate ) { if (!dtStartTime.isValid()) throw( "StartTime is invalid" ); // ------------------------------------------------------------------ // Read Recording From Database // ------------------------------------------------------------------ ProgramInfo pginfo( (uint)nChanId, dtStartTime ); if (!pginfo.GetChanID()) { LOG( VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed") .arg( nChanId ) .arg( dtStartTime.toString() )); return NULL; } if ( pginfo.GetHostname().toLower() != gCoreContext->GetHostName().toLower()) { // We only handle requests for local resources QString sMsg = QString("GetRecording: Wrong Host '%1' request from '%2'.") .arg( gCoreContext->GetHostName()) .arg( pginfo.GetHostname() ); LOG(VB_UPNP, LOG_ERR, sMsg); throw HttpRedirectException( pginfo.GetHostname() ); } QString sFileName( GetPlaybackURL(&pginfo) ); // ---------------------------------------------------------------------- // check to see if the file exists // ---------------------------------------------------------------------- if (!QFile::exists( sFileName )) { LOG( VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed") .arg( nChanId ) .arg( dtStartTime.toString() )); return NULL; } QFileInfo fInfo( sFileName ); return AddLiveStream( pginfo.GetStorageGroup(), fInfo.fileName(), pginfo.GetHostname(), nMaxSegments, nWidth, nHeight, nBitrate, nAudioBitrate, nSampleRate ); }
DTC::LiveStreamInfo *Content::AddVideoLiveStream( int nId, int nMaxSegments, int nWidth, int nHeight, int nBitrate, int nAudioBitrate, int nSampleRate ) { if (nId < 0) throw( "Id is invalid" ); VideoMetadataListManager::VideoMetadataPtr metadata = VideoMetadataListManager::loadOneFromDatabase(nId); if (!metadata) { LOG( VB_UPNP, LOG_ERR, QString("AddVideoLiveStream - no metadata for %1") .arg( nId )); return NULL; } if ( metadata->GetHost().toLower() != gCoreContext->GetHostName().toLower()) { // We only handle requests for local resources QString sMsg = QString("AddVideoLiveStream: Wrong Host '%1' request from '%2'.") .arg( gCoreContext->GetHostName()) .arg( metadata->GetHost() ); LOG(VB_UPNP, LOG_ERR, sMsg); throw HttpRedirectException( metadata->GetHost() ); } StorageGroup sg("Videos", metadata->GetHost()); QString sFileName = sg.FindFile(metadata->GetFilename()); // ---------------------------------------------------------------------- // check to see if the file exists // ---------------------------------------------------------------------- if (!QFile::exists( sFileName )) { LOG( VB_UPNP, LOG_ERR, QString("AddVideoLiveStream - file does not exist.")); return NULL; } return AddLiveStream( "Videos", metadata->GetFilename(), metadata->GetHost(), nMaxSegments, nWidth, nHeight, nBitrate, nAudioBitrate, nSampleRate ); }
DTC::LiveStreamInfo *Content::AddRecordingLiveStream( int nRecordedId, int nChanId, const QDateTime &recstarttsRaw, int nMaxSegments, int nWidth, int nHeight, int nBitrate, int nAudioBitrate, int nSampleRate ) { if ((nRecordedId <= 0) && (nChanId <= 0 || !recstarttsRaw.isValid())) throw QString("Recorded ID or Channel ID and StartTime appears invalid."); // ------------------------------------------------------------------ // Read Recording From Database // ------------------------------------------------------------------ // TODO Should use RecordingInfo ProgramInfo pginfo; if (nRecordedId > 0) pginfo = ProgramInfo(nRecordedId); else pginfo = ProgramInfo(nChanId, recstarttsRaw.toUTC()); if (!pginfo.GetChanID()) { LOG(VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed") .arg(QString::number(nRecordedId))); return NULL; } if (pginfo.GetHostname().toLower() != gCoreContext->GetHostName().toLower()) { // We only handle requests for local resources QString sMsg = QString("GetRecording: Wrong Host '%1' request from '%2'.") .arg( gCoreContext->GetHostName()) .arg( pginfo.GetHostname() ); LOG(VB_UPNP, LOG_ERR, sMsg); throw HttpRedirectException( pginfo.GetHostname() ); } QString sFileName( GetPlaybackURL(&pginfo) ); // ---------------------------------------------------------------------- // check to see if the file exists // ---------------------------------------------------------------------- if (!QFile::exists( sFileName )) { LOG( VB_UPNP, LOG_ERR, QString("AddRecordingLiveStream - for %1, %2 failed") .arg( nChanId ) .arg( recstarttsRaw.toUTC().toString() )); return NULL; } QFileInfo fInfo( sFileName ); return AddLiveStream( pginfo.GetStorageGroup(), fInfo.fileName(), pginfo.GetHostname(), nMaxSegments, nWidth, nHeight, nBitrate, nAudioBitrate, nSampleRate ); }