--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -281,42 +281,42 @@ bool VideoData::SetVideoDataToImage(Plan
}
/* static */
already_AddRefed<VideoData>
VideoData::CreateAndCopyData(const VideoInfo& aInfo,
ImageContainer* aContainer,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const TimeUnit& aDuration,
const YCbCrBuffer& aBuffer,
bool aKeyframe,
int64_t aTimecode,
const IntRect& aPicture)
{
if (!aContainer) {
// Create a dummy VideoData with no image. This gives us something to
// send to media streams if necessary.
RefPtr<VideoData> v(new VideoData(aOffset,
aTime,
- aDuration,
+ aDuration.ToMicroseconds(),
aKeyframe,
aTimecode,
aInfo.mDisplay,
0));
return v.forget();
}
if (!ValidateBufferAndPicture(aBuffer, aPicture)) {
return nullptr;
}
RefPtr<VideoData> v(new VideoData(aOffset,
aTime,
- aDuration,
+ aDuration.ToMicroseconds(),
aKeyframe,
aTimecode,
aInfo.mDisplay,
0));
#ifdef MOZ_WIDGET_GONK
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
@@ -365,43 +365,43 @@ VideoData::CreateAndCopyData(const Video
/* static */
already_AddRefed<VideoData>
VideoData::CreateAndCopyData(const VideoInfo& aInfo,
ImageContainer* aContainer,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const TimeUnit& aDuration,
const YCbCrBuffer& aBuffer,
const YCbCrBuffer::Plane &aAlphaPlane,
bool aKeyframe,
int64_t aTimecode,
const IntRect& aPicture)
{
if (!aContainer) {
// Create a dummy VideoData with no image. This gives us something to
// send to media streams if necessary.
RefPtr<VideoData> v(new VideoData(aOffset,
aTime,
- aDuration,
+ aDuration.ToMicroseconds(),
aKeyframe,
aTimecode,
aInfo.mDisplay,
0));
return v.forget();
}
if (!ValidateBufferAndPicture(aBuffer, aPicture)) {
return nullptr;
}
RefPtr<VideoData> v(new VideoData(aOffset,
aTime,
- aDuration,
+ aDuration.ToMicroseconds(),
aKeyframe,
aTimecode,
aInfo.mDisplay,
0));
// Convert from YUVA to BGRA format on the software side.
RefPtr<layers::SharedRGBImage> videoImage =
aContainer->CreateSharedRGBImage();
@@ -431,24 +431,24 @@ VideoData::CreateAndCopyData(const Video
return v.forget();
}
/* static */
already_AddRefed<VideoData>
VideoData::CreateFromImage(const IntSize& aDisplay,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const TimeUnit& aDuration,
const RefPtr<Image>& aImage,
bool aKeyframe,
int64_t aTimecode)
{
RefPtr<VideoData> v(new VideoData(aOffset,
aTime,
- aDuration,
+ aDuration.ToMicroseconds(),
aKeyframe,
aTimecode,
aDisplay,
0));
v->mImage = aImage;
return v.forget();
}
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -484,49 +484,49 @@ public:
// Creates a new VideoData containing a deep copy of aBuffer. May use
// aContainer to allocate an Image to hold the copied data.
static already_AddRefed<VideoData> CreateAndCopyData(
const VideoInfo& aInfo,
ImageContainer* aContainer,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const media::TimeUnit& aDuration,
const YCbCrBuffer& aBuffer,
bool aKeyframe,
int64_t aTimecode,
const IntRect& aPicture);
static already_AddRefed<VideoData> CreateAndCopyData(
const VideoInfo& aInfo,
ImageContainer* aContainer,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const media::TimeUnit& aDuration,
const YCbCrBuffer& aBuffer,
const YCbCrBuffer::Plane& aAlphaPlane,
bool aKeyframe,
int64_t aTimecode,
const IntRect& aPicture);
static already_AddRefed<VideoData> CreateAndCopyIntoTextureClient(
const VideoInfo& aInfo,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const media::TimeUnit& aDuration,
layers::TextureClient* aBuffer,
bool aKeyframe,
int64_t aTimecode,
const IntRect& aPicture);
static already_AddRefed<VideoData> CreateFromImage(
const IntSize& aDisplay,
int64_t aOffset,
int64_t aTime,
- int64_t aDuration,
+ const media::TimeUnit& aDuration,
const RefPtr<Image>& aImage,
bool aKeyframe,
int64_t aTimecode);
// Initialize PlanarYCbCrImage. Only When aCopyData is true,
// video data is copied to PlanarYCbCrImage.
static bool SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
const VideoInfo& aInfo,
--- a/dom/media/android/AndroidMediaReader.cpp
+++ b/dom/media/android/AndroidMediaReader.cpp
@@ -171,17 +171,17 @@ bool AndroidMediaReader::DecodeVideoFram
int64_t pos = mDecoder->GetResource()->Tell();
IntRect picture = mPicture;
RefPtr<VideoData> v;
if (currentImage) {
v = VideoData::CreateFromImage(mInfo.mVideo.mDisplay,
pos,
frame.mTimeUs,
- 1, // We don't know the duration yet.
+ TimeUnit::FromMicroseconds(1), // We don't know the duration yet.
currentImage,
frame.mKeyFrame,
-1);
} else {
// Assume YUV
VideoData::YCbCrBuffer b;
b.mPlanes[0].mData = static_cast<uint8_t *>(frame.Y.mData);
b.mPlanes[0].mStride = frame.Y.mStride;
@@ -216,17 +216,17 @@ bool AndroidMediaReader::DecodeVideoFram
picture.height = (frame.Y.mHeight * mPicture.height) / mInitialFrame.height;
}
// This is the approximate byte position in the stream.
v = VideoData::CreateAndCopyData(mInfo.mVideo,
mDecoder->GetImageContainer(),
pos,
frame.mTimeUs,
- 1, // We don't know the duration yet.
+ TimeUnit::FromMicroseconds(1), // We don't know the duration yet.
b,
frame.mKeyFrame,
-1,
picture);
}
if (!v) {
return false;
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -631,25 +631,26 @@ ChromiumCDMParent::RecvDecoded(const CDM
b.mPlanes[2].mData = data;
b.mPlanes[2].mWidth = (aFrame.mImageWidth() + 1) / 2;
b.mPlanes[2].mHeight = (aFrame.mImageHeight() + 1) / 2;
b.mPlanes[2].mStride = aFrame.mVPlane().mStride();
b.mPlanes[2].mOffset = aFrame.mVPlane().mPlaneOffset();
b.mPlanes[2].mSkip = 0;
gfx::IntRect pictureRegion(0, 0, aFrame.mImageWidth(), aFrame.mImageHeight());
- RefPtr<VideoData> v = VideoData::CreateAndCopyData(mVideoInfo,
- mImageContainer,
- mLastStreamOffset,
- aFrame.mTimestamp(),
- aFrame.mDuration(),
- b,
- false,
- -1,
- pictureRegion);
+ RefPtr<VideoData> v = VideoData::CreateAndCopyData(
+ mVideoInfo,
+ mImageContainer,
+ mLastStreamOffset,
+ aFrame.mTimestamp(),
+ media::TimeUnit::FromMicroseconds(aFrame.mDuration()),
+ b,
+ false,
+ -1,
+ pictureRegion);
// Return the shmem to the CDM so the shmem can be reused to send us
// another frame.
if (!SendGiveBuffer(aFrame.mData())) {
mDecodePromise.RejectIfExists(
MediaResult(NS_ERROR_OUT_OF_MEMORY,
RESULT_DETAIL("Can't return shmem to CDM process")),
__func__);
--- a/dom/media/ipc/VideoDecoderChild.cpp
+++ b/dom/media/ipc/VideoDecoderChild.cpp
@@ -40,23 +40,25 @@ VideoDecoderChild::RecvOutput(const Vide
{
AssertOnManagerThread();
// The Image here creates a TextureData object that takes ownership
// of the SurfaceDescriptor, and is responsible for making sure that
// it gets deallocated.
RefPtr<Image> image = new GPUVideoImage(GetManager(), aData.sd(), aData.frameSize());
- RefPtr<VideoData> video = VideoData::CreateFromImage(aData.display(),
- aData.base().offset(),
- aData.base().time(),
- aData.base().duration(),
- image,
- aData.base().keyframe(),
- aData.base().timecode());
+ RefPtr<VideoData> video = VideoData::CreateFromImage(
+ aData.display(),
+ aData.base().offset(),
+ aData.base().time(),
+ media::TimeUnit::FromMicroseconds(aData.base().duration()),
+ image,
+ aData.base().keyframe(),
+ aData.base().timecode());
+
mDecodedData.AppendElement(Move(video));
return IPC_OK();
}
mozilla::ipc::IPCResult
VideoDecoderChild::RecvInputExhausted()
{
AssertOnManagerThread();
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -71,17 +71,17 @@ BlankVideoDataCreator::Create(MediaRawDa
buffer.mPlanes[2].mWidth = (mFrameWidth + 1) / 2;
buffer.mPlanes[2].mOffset = 0;
buffer.mPlanes[2].mSkip = 0;
return VideoData::CreateAndCopyData(mInfo,
mImageContainer,
aSample->mOffset,
aSample->mTime,
- aSample->mDuration.ToMicroseconds(),
+ aSample->mDuration,
buffer,
aSample->mKeyframe,
aSample->mTime,
mPicture);
}
BlankAudioDataCreator::BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
: mFrameSum(0), mChannelCount(aChannelCount), mSampleRate(aSampleRate)
--- a/dom/media/platforms/agnostic/TheoraDecoder.cpp
+++ b/dom/media/platforms/agnostic/TheoraDecoder.cpp
@@ -167,17 +167,17 @@ TheoraDecoder::ProcessDecode(MediaRawDat
VideoInfo info;
info.mDisplay = mInfo.mDisplay;
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(info,
mImageContainer,
aSample->mOffset,
aSample->mTime,
- aSample->mDuration.ToMicroseconds(),
+ aSample->mDuration,
b,
aSample->mKeyframe,
aSample->mTimecode,
mInfo.ScaledImageRect(mTheoraInfo.frame_width,
mTheoraInfo.frame_height));
if (!v) {
LOG(
"Image allocation error source %ux%u display %ux%u picture %ux%u",
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -203,34 +203,34 @@ VPXDecoder::ProcessDecode(MediaRawData*
}
RefPtr<VideoData> v;
if (!img_alpha) {
v = VideoData::CreateAndCopyData(mInfo,
mImageContainer,
aSample->mOffset,
aSample->mTime,
- aSample->mDuration.ToMicroseconds(),
+ aSample->mDuration,
b,
aSample->mKeyframe,
aSample->mTimecode,
mInfo.ScaledImageRect(img->d_w,
img->d_h));
} else {
VideoData::YCbCrBuffer::Plane alpha_plane;
alpha_plane.mData = img_alpha->planes[0];
alpha_plane.mStride = img_alpha->stride[0];
alpha_plane.mHeight = img_alpha->d_h;
alpha_plane.mWidth = img_alpha->d_w;
alpha_plane.mOffset = alpha_plane.mSkip = 0;
v = VideoData::CreateAndCopyData(mInfo,
mImageContainer,
aSample->mOffset,
aSample->mTime,
- aSample->mDuration.ToMicroseconds(),
+ aSample->mDuration,
b,
alpha_plane,
aSample->mKeyframe,
aSample->mTimecode,
mInfo.ScaledImageRect(img->d_w,
img->d_h));
}
--- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp
@@ -57,26 +57,26 @@ GMPVideoDecoder::Decoded(GMPVideoi420Fra
b.mPlanes[i].mHeight = (decodedFrame->Height() + 1) / 2;
}
b.mPlanes[i].mOffset = 0;
b.mPlanes[i].mSkip = 0;
}
gfx::IntRect pictureRegion(
0, 0, decodedFrame->Width(), decodedFrame->Height());
- RefPtr<VideoData> v =
- VideoData::CreateAndCopyData(mConfig,
- mImageContainer,
- mLastStreamOffset,
- decodedFrame->Timestamp(),
- decodedFrame->Duration(),
- b,
- false,
- -1,
- pictureRegion);
+ RefPtr<VideoData> v = VideoData::CreateAndCopyData(
+ mConfig,
+ mImageContainer,
+ mLastStreamOffset,
+ decodedFrame->Timestamp(),
+ media::TimeUnit::FromMicroseconds(decodedFrame->Duration()),
+ b,
+ false,
+ -1,
+ pictureRegion);
RefPtr<GMPVideoDecoder> self = this;
if (v) {
mDecodedData.AppendElement(Move(v));
} else {
mDecodedData.Clear();
mDecodePromise.RejectIfExists(
MediaResult(NS_ERROR_OUT_OF_MEMORY,
RESULT_DETAIL("CallBack::CreateAndCopyData")),
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -133,17 +133,18 @@ public:
}
if (size > 0) {
RefPtr<layers::Image> img = new SurfaceTextureImage(
mDecoder->mSurfaceTexture.get(), inputInfo.mImageSize,
gl::OriginPos::BottomLeft);
RefPtr<VideoData> v = VideoData::CreateFromImage(
- inputInfo.mDisplaySize, offset, presentationTimeUs, inputInfo.mDurationUs,
+ inputInfo.mDisplaySize, offset, presentationTimeUs,
+ TimeUnit::FromMicroseconds(inputInfo.mDurationUs),
img, !!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME),
presentationTimeUs);
v->SetListener(Move(releaseSample));
mDecoder->UpdateOutputStatus(v);
}
if (isEOS) {
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp
+++ b/dom/media/platforms/apple/AppleVTDecoder.cpp
@@ -408,17 +408,17 @@ AppleVTDecoder::OutputFrame(CVPixelBuffe
mPictureHeight);
// Copy the image data into our own format.
data =
VideoData::CreateAndCopyData(info,
mImageContainer,
aFrameRef.byte_offset,
aFrameRef.composition_timestamp.ToMicroseconds(),
- aFrameRef.duration.ToMicroseconds(),
+ aFrameRef.duration,
buffer,
aFrameRef.is_sync_point,
aFrameRef.decode_timestamp.ToMicroseconds(),
visible);
// Unlock the returned image data.
CVPixelBufferUnlockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
} else {
#ifndef MOZ_WIDGET_UIKIT
@@ -428,17 +428,17 @@ AppleVTDecoder::OutputFrame(CVPixelBuffe
RefPtr<MacIOSurface> macSurface = new MacIOSurface(surface);
RefPtr<layers::Image> image = new MacIOSurfaceImage(macSurface);
data =
VideoData::CreateFromImage(info.mDisplay,
aFrameRef.byte_offset,
aFrameRef.composition_timestamp.ToMicroseconds(),
- aFrameRef.duration.ToMicroseconds(),
+ aFrameRef.duration,
image.forget(),
aFrameRef.is_sync_point,
aFrameRef.decode_timestamp.ToMicroseconds());
#else
MOZ_ASSERT_UNREACHABLE("No MacIOSurface on iOS");
#endif
}
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -335,17 +335,17 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
break;
}
}
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,
mImageContainer,
aSample->mOffset,
pts,
- duration,
+ media::TimeUnit::FromMicroseconds(duration),
b,
!!mFrame->key_frame,
-1,
mInfo.ScaledImageRect(mFrame->width,
mFrame->height));
if (!v) {
return MediaResult(NS_ERROR_OUT_OF_MEMORY,
--- a/dom/media/platforms/omx/OmxDataDecoder.cpp
+++ b/dom/media/platforms/omx/OmxDataDecoder.cpp
@@ -990,17 +990,17 @@ MediaDataHelper::CreateYUV420VideoData(B
b.mPlanes[2].mSkip = 0;
VideoInfo info(*mTrackInfo->GetAsVideoInfo());
RefPtr<VideoData> data =
VideoData::CreateAndCopyData(info,
mImageContainer,
0, // Filled later by caller.
0, // Filled later by caller.
- 1, // We don't know the duration.
+ media::TimeUnit::FromMicroseconds(1), // We don't know the duration.
b,
0, // Filled later by caller.
-1,
info.ImageRect());
LOG("YUV420 VideoData: disp width %d, height %d, pic width %d, height %d, time %lld",
info.mDisplay.width, info.mDisplay.height, info.mImage.width,
info.mImage.height, aBufferData->mBuffer->nTimeStamp);
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -834,17 +834,17 @@ WMFVideoMFTManager::CreateBasicVideoFram
LayersBackend backend = GetCompositorBackendType(mKnowsCompositor);
if (backend != LayersBackend::LAYERS_D3D11) {
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mVideoInfo,
mImageContainer,
aStreamOffset,
pts.ToMicroseconds(),
- duration.ToMicroseconds(),
+ duration,
b,
false,
-1,
pictureRegion);
if (twoDBuffer) {
twoDBuffer->Unlock2D();
} else {
buffer->Unlock();
@@ -861,17 +861,17 @@ WMFVideoMFTManager::CreateBasicVideoFram
b,
pictureRegion,
false);
RefPtr<VideoData> v =
VideoData::CreateFromImage(mVideoInfo.mDisplay,
aStreamOffset,
pts.ToMicroseconds(),
- duration.ToMicroseconds(),
+ duration,
image.forget(),
false,
-1);
v.forget(aOutVideoData);
return S_OK;
}
@@ -899,17 +899,17 @@ WMFVideoMFTManager::CreateD3DVideoFrame(
media::TimeUnit pts = GetSampleTime(aSample);
NS_ENSURE_TRUE(pts.IsValid(), E_FAIL);
media::TimeUnit duration = GetSampleDuration(aSample);
NS_ENSURE_TRUE(duration.IsValid(), E_FAIL);
RefPtr<VideoData> v = VideoData::CreateFromImage(mVideoInfo.mDisplay,
aStreamOffset,
pts.ToMicroseconds(),
- duration.ToMicroseconds(),
+ duration,
image.forget(),
false,
-1);
NS_ENSURE_TRUE(v, E_FAIL);
v.forget(aOutVideoData);
return S_OK;