mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1261900: [webm] Use block duration if known. r=kinetik
This commit is contained in:
parent
c3e2181bd1
commit
7a284b30ab
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user