Bug 1103848 - Part 1. Hint existing output streams as tracks become known. r=roc

This commit is contained in:
Andreas Pehrson 2014-11-24 23:53:00 +01:00
parent be0fa8a339
commit d8270a86d0
2 changed files with 19 additions and 6 deletions

View File

@ -2903,6 +2903,14 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
mDecoder->SetFragmentEndTime(mFragmentEnd);
}
// Tracks just got known, pass the info along to the output streams
uint8_t hints = (mHasAudio ? DOMMediaStream::HINT_CONTENTS_AUDIO : 0) |
(mHasVideo ? DOMMediaStream::HINT_CONTENTS_VIDEO : 0);
for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) {
OutputMediaStream* out = &mOutputStreams[i];
out->mStream->SetHintContents(hints);
}
// If this element had a video track, but consists only of an audio track now,
// delete the VideoFrameContainer. This happens when the src is changed to an
// audio only file.

View File

@ -54,8 +54,8 @@ public:
if (!track) {
stream->CreateDOMTrack(mID, mType);
track = stream->BindDOMTrack(mID, mType);
stream->NotifyMediaStreamTrackCreated(track);
}
stream->NotifyMediaStreamTrackCreated(track);
} else {
track = stream->GetDOMTrackFor(mID);
}
@ -325,13 +325,16 @@ DOMMediaStream::RemovePrincipalChangeObserver(PrincipalChangeObserver* aObserver
void
DOMMediaStream::SetHintContents(TrackTypeHints aHintContents)
{
mHintContents = aHintContents;
if (aHintContents & HINT_CONTENTS_AUDIO) {
CreateDOMTrack(kAudioTrack, MediaSegment::AUDIO);
}
if (aHintContents & HINT_CONTENTS_VIDEO) {
TrackTypeHints oldHintContents = mHintContents;
mHintContents |= aHintContents;
if (aHintContents & HINT_CONTENTS_VIDEO &&
!(oldHintContents & HINT_CONTENTS_VIDEO)) {
CreateDOMTrack(kVideoTrack, MediaSegment::VIDEO);
}
if (aHintContents & HINT_CONTENTS_AUDIO &&
!(oldHintContents & HINT_CONTENTS_AUDIO)) {
CreateDOMTrack(kAudioTrack, MediaSegment::AUDIO);
}
}
MediaStreamTrack*
@ -340,9 +343,11 @@ DOMMediaStream::CreateDOMTrack(TrackID aTrackID, MediaSegment::Type aType)
MediaStreamTrack* track;
switch (aType) {
case MediaSegment::AUDIO:
mHintContents |= HINT_CONTENTS_AUDIO;
track = new AudioStreamTrack(this, aTrackID);
break;
case MediaSegment::VIDEO:
mHintContents |= HINT_CONTENTS_VIDEO;
track = new VideoStreamTrack(this, aTrackID);
break;
default: