Bug 1261900: [webm] Use block duration if known. r=kinetik

This commit is contained in:
Jean-Yves Avenard 2016-04-21 21:07:54 +10:00
Родитель c3e2181bd1
Коммит 7a284b30ab
2 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -19,7 +19,12 @@ namespace mozilla {
class NesteggPacketHolder {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NesteggPacketHolder)
NesteggPacketHolder() : mPacket(nullptr), mOffset(-1), mTimestamp(-1), mIsKeyframe(false) {}
NesteggPacketHolder()
: mPacket(nullptr)
, mOffset(-1)
, mTimestamp(-1)
, mDuration(-1)
, mIsKeyframe(false) {}
bool Init(nestegg_packet* aPacket, int64_t aOffset, unsigned aTrack, bool aIsKeyframe)
{
@ -36,12 +41,17 @@ public:
mTrack = aTrack;
mIsKeyframe = aIsKeyframe;
uint64_t duration_ns;
if (!nestegg_packet_duration(aPacket, &duration_ns)) {
mDuration = duration_ns / 1000;
}
return true;
}
nestegg_packet* Packet() { MOZ_ASSERT(IsInitialized()); return mPacket; }
int64_t Offset() { MOZ_ASSERT(IsInitialized()); return mOffset; }
int64_t Timestamp() { MOZ_ASSERT(IsInitialized()); return mTimestamp; }
int64_t Duration() { MOZ_ASSERT(IsInitialized()); return mDuration; }
unsigned Track() { MOZ_ASSERT(IsInitialized()); return mTrack; }
bool IsKeyframe() { MOZ_ASSERT(IsInitialized()); return mIsKeyframe; }
@ -62,6 +72,9 @@ private:
// Packet presentation timestamp in microseconds.
int64_t mTimestamp;
// Packet duration in microseconds; -1 if unknown or retrieval failed.
int64_t mDuration;
// Track ID.
unsigned mTrack;

Просмотреть файл

@ -510,8 +510,9 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
return false;
}
int64_t tstamp = holder->Timestamp();
int64_t duration = holder->Duration();
// The end time of this frame is the start time of the next frame. Fetch
// The end time of this frame is the start time of the next frame. Fetch
// the timestamp of the next packet for this track. If we've reached the
// end of the resource, use the file's duration as the end time of this
// video frame.
@ -521,6 +522,8 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
if (next_holder) {
next_tstamp = next_holder->Timestamp();
PushAudioPacket(next_holder);
} else if (duration >= 0) {
next_tstamp = tstamp + duration;
} else if (!mIsMediaSource ||
(mIsMediaSource && mLastAudioFrameTime.isSome())) {
next_tstamp = tstamp;
@ -534,6 +537,8 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
if (next_holder) {
next_tstamp = next_holder->Timestamp();
PushVideoPacket(next_holder);
} else if (duration >= 0) {
next_tstamp = tstamp + duration;
} else if (!mIsMediaSource ||
(mIsMediaSource && mLastVideoFrameTime.isSome())) {
next_tstamp = tstamp;