/* Thread that does the buffering of segments */ void* DASHReceiver::DoBuffering (void *receiver) { DASHReceiver *dashreceiver = (DASHReceiver *) receiver; uint32_t number = 0; MediaObject *media = dashreceiver->logic->GetSegment(number); while(media != NULL) { media->StartDownload(); media->WaitFinished(); dashreceiver->buffer->Push(media); number++; /* Just for demonstration purpose * * Do something with the HTTPHeader... * e.g. parse it for "Content-Length:" to retrieve the segment size in bytes */ std::string header = media->GetHTTPTransactionList().at(0)->HTTPHeader(); media = dashreceiver->logic->GetSegment(number); std::cout << "Buffer size in segments: " << dashreceiver->buffer->Length() << std::endl; } dashreceiver->buffer->SetEOS(true); return NULL; }
/* Thread that does the buffering of segments */ void* DASHReceiver::DoBuffering (void *receiver) { DASHReceiver *dashReceiver = (DASHReceiver *) receiver; dashReceiver->DownloadInitSegment(dashReceiver->GetRepresentation()); MediaObject *media = dashReceiver->GetNextSegment(); //media = dashReceiver->GetNextSegment(); while(media != NULL && dashReceiver->isBuffering) { media->StartDownload(); if (!dashReceiver->buffer->PushBack(media)) { delete(media); media = NULL; return NULL; } media->WaitFinished(); dashReceiver->NotifySegmentDownloaded(); media = dashReceiver->GetNextSegment(); } dashReceiver->buffer->SetEOS(true); return NULL; }
/* Thread that does the buffering of segments */ void* DASHManager::DoBuffering (void *receiver) { DASHManager *dashmanager = (DASHManager *) receiver; MediaObject *media = dashmanager->logic->GetSegment(); while(media != NULL && dashmanager->isDownloading) { media->StartDownload(); if (!dashmanager->buffer->PushBack(media)) return NULL; media->WaitFinished(); /* Just for demonstration purpose * * Do something with the HTTPHeader... * e.g. parse it for "Content-Length:" to retrieve the segment size in bytes */ std::string header = media->GetHTTPTransactionList().at(0)->HTTPHeader(); dashmanager->NotifySegmentDownloaded(); media = dashmanager->logic->GetSegment(); } dashmanager->buffer->SetEOS(true); return NULL; }
int main(){ /* test des objets */ MediaObject* m = new MediaObject ("m",1,"C/Desktop"); m->print(); MediaObject** tab = new MediaObject*[5]; unsigned int count = 0; tab[count++] = new Photo ("test_1",1 ,"C/Desktop", "Telecom"); tab[count++] = new Video ("test_2",2 ,"C/Desktop", 15); tab[count++] = new Photo("test_3",3 ,"C/Desktop", "Bordeaux"); tab[count++] = new Video("test_4",4 ,"C/Desktop", 35); tab[count++] = new Video("test_5",2 ,"C/Desktop", 40); for(int i=0; i<5; i++) { tab[i]->print(); cout << "\n"; } cout << "\ntest de film et des tableaux"; int chapters [3] = {1, 2, 3}; Film* film_1= new Film ("premierFilm", 1258,"~/Desktop",50,3,chapters); film_1->print(); chapters[0] = 5; // on verifie que le tableau a bien etait copie film_1->print(); }
bool Backend::endConnectionChange(QSet<QObject *> objects) { //end of a transaction for(QSet<QObject *>::const_iterator it = objects.begin(); it != objects.end(); ++it) { if (BackendNode *node = qobject_cast<BackendNode*>(*it)) { MediaObject *mo = node->mediaObject(); if (mo) { switch(mo->transactionState) { case Phonon::ErrorState: case Phonon::StoppedState: case Phonon::LoadingState: //nothing to do break; case Phonon::PausedState: mo->transactionState = Phonon::StoppedState; mo->pause(); break; default: mo->transactionState = Phonon::StoppedState; mo->play(); break; } if (mo->state() == Phonon::ErrorState) return false; } } } return true; }
foreach (QObject *object, objects) { MediaNode *sourceNode = qobject_cast<MediaNode *>(object); MediaObject *media = sourceNode->root(); if (media) { media->saveState(); return true; } }
bool Backend::connectNodes(QObject *node1, QObject *node2) { MediaObject *mediaObject = qobject_cast<MediaObject*> (node1); AudioOutput *audioOutput = qobject_cast<AudioOutput*> (node2); if (mediaObject && audioOutput) mediaObject->setAudioOutput(audioOutput); return true; }
MediaObject *createPlayer(Phonon::Category category, const MediaSource &source) { MediaObject *mo = new MediaObject; AudioOutput *ao = new AudioOutput(category, mo); createPath(mo, ao); if (isPlayable(source.type())) { mo->setCurrentSource(source); } return mo; }
void Player::handleMetadataChanged () { MediaObject *object = qobject_cast<MediaObject*> (sender ()); if (!object) { qWarning () << Q_FUNC_INFO << "not a MediaObject" << object; return; } MediaSource source = object->currentSource (); for (int i = 0; i < QueueModel_->rowCount (); ++i) { QStandardItem *item = QueueModel_->item (i); if (source == *item->data (SourceRole).value<MediaSource*> ()) { QStringList title = object->metaData (TitleMetaData); QStringList album = object->metaData (AlbumMetaData); QStringList artist = object->metaData (ArtistMetaData); QString text; if (!title.isEmpty () && !title.at (0).isEmpty ()) { text += title.at (0); text += " - "; } if (!album.isEmpty () && !album.at (0).isEmpty ()) { text += album.at (0); text += " - "; } if (!artist.isEmpty () && !artist.at (0).isEmpty ()) { text += artist.at (0); text += " - "; } text = text.left (text.size () - 3); if (!text.isEmpty ()) item->setText (text); break; } } if (object != Ui_.Player_->GetMediaObject ()) object->deleteLater (); }
/// Handle events (basically just pass it on) void AudioDataOutput::upstreamEvent(Event *e) { Q_ASSERT(e); if (e->type() == Event::IsThereAXineEngineForMe) { // yes there is MediaObject *mediaObject = dynamic_cast<MediaObject*>(m_source); //TODO; qobject_cast? if (mediaObject) { SourceNode::downstreamEvent(new HeresYourXineStreamEvent(mediaObject->stream())); m_mediaObject = mediaObject; } } else SourceNode::upstreamEvent(e); }
void DASHReceiver::DownloadInitSegment (IRepresentation* rep) { if (this->InitSegmentExists(rep)) return; MediaObject *initSeg = NULL; initSeg = this->GetInitSegment(); if (initSeg) { initSeg->StartDownload(); this->initSegments[rep] = initSeg; } }
static QByteArray debugMediaObject(const MediaObject& mediaObject) { QByteArray byteArray; QTextStream stream(&byteArray); const QMetaObject* metaObject = mediaObject.metaObject(); QMetaEnum phononStates = metaObject->enumerator(metaObject->indexOfEnumerator("PhononState")); stream << "Phonon::MediaObject("; stream << "State:" << phononStates.valueToKey(mediaObject.state()); stream << "| Current time:" << mediaObject.currentTime(); stream << "| Remaining time:" << mediaObject.remainingTime(); stream << "| Total time:" << mediaObject.totalTime(); stream << "| Meta-data:"; QMultiMap<QString, QString> map = mediaObject.metaData(); for (QMap<QString, QString>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) { stream << "(" << it.key() << ", " << it.value() << ")"; } stream << "| Has video:" << mediaObject.hasVideo(); stream << "| Is seekable:" << mediaObject.isSeekable(); stream << ")"; stream.flush(); return byteArray; }
bool DASHManager::CreateAVDecoder () { MediaObject *mediaObject = this->buffer->GetFront(); // initSegForMediaObject may be NULL => BaseUrls if (!mediaObject){ LOGE("Failed to fetch MediaObject"); return false; } MediaObject *initSegForMediaObject = this->receiver->FindInitSegment(mediaObject->GetRepresentation()); this->mediaObjectDecoder = new MediaObjectDecoder(initSegForMediaObject, mediaObject, this); return this->mediaObjectDecoder->Start(); }
int DASHReceiver::IORead (uint8_t *buf, int buf_size) { /* FFMpeg callback that consumes data from the buffer for decoding */ MediaObject *media = this->buffer->Front(); if(media == NULL) return 0; int ret = media->Read(buf, buf_size); if(ret == 0) this->buffer->Pop(); else return ret; return this->IORead(buf, buf_size); }
int DASHManager::Read (uint8_t *buf, int buf_size) { /* FFMpeg callback that consumes data from the buffer for decoding */ MediaObject *media = this->buffer->Front(); if(media == NULL) return 0; int ret = media->Read(buf, buf_size); if(ret == 0) this->buffer->PopFront(); else return ret; this->readSegmentCount++; this->NotifySegmentDecodingStarted(); return this->Read(buf, buf_size); }
void CALLBACK MediaObject::WaveOutCallBack(HWAVEOUT m_hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { Q_UNUSED(m_hWaveOut); Q_UNUSED(dwInstance); Q_UNUSED(dwParam2); switch(uMsg) { case WOM_OPEN: break; case WOM_DONE: { WAVEHDR *waveHeader = (WAVEHDR*)dwParam1; MediaObject* mediaObject = reinterpret_cast<MediaObject *>(waveHeader->dwUser); if (mediaObject) { mediaObject->swapBuffers(); } } break; case WOM_CLOSE: break; } }
/* Thread that does the buffering of segments */ void* DASHReceiver::DoBuffering (void *receiver) { DASHReceiver *dashreceiver = (DASHReceiver *) receiver; uint32_t number = 0; MediaObject *media = dashreceiver->logic->GetSegment(number); while(media != NULL) { media->StartDownload(); media->WaitFinished(); dashreceiver->buffer->Push(media); number++; media = dashreceiver->logic->GetSegment(number); std::cout << "Buffer size in segments: " << dashreceiver->buffer->Length() << std::endl; } dashreceiver->buffer->SetEOS(true); return NULL; }