mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1876414 - Let SetVideoDataToImage return MediaResult r=media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D200568
This commit is contained in:
parent
9d206aa4a4
commit
af045ec3b4
@ -299,18 +299,24 @@ PlanarYCbCrData ConstructPlanarYCbCrData(const VideoInfo& aInfo,
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
const VideoInfo& aInfo,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
const IntRect& aPicture, bool aCopyData) {
|
||||
MediaResult VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
const VideoInfo& aInfo,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
const IntRect& aPicture,
|
||||
bool aCopyData) {
|
||||
MOZ_ASSERT(aVideoImage);
|
||||
|
||||
PlanarYCbCrData data = ConstructPlanarYCbCrData(aInfo, aBuffer, aPicture);
|
||||
|
||||
if (aCopyData) {
|
||||
return aVideoImage->CopyData(data);
|
||||
// TODO: PlanarYCbCrImage::CopyData may return false on non out-of-memory
|
||||
// failures.
|
||||
return MediaResult(
|
||||
aVideoImage->CopyData(data) ? NS_OK : NS_ERROR_OUT_OF_MEMORY,
|
||||
RESULT_DETAIL("Failed to copy image data"));
|
||||
}
|
||||
return aVideoImage->AdoptData(data);
|
||||
return MediaResult(aVideoImage->AdoptData(data) ? NS_OK : NS_ERROR_UNEXPECTED,
|
||||
RESULT_DETAIL("Failed to adopt image data"));
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -367,12 +373,10 @@ Result<already_AddRefed<VideoData>, MediaResult> VideoData::CreateAndCopyData(
|
||||
PlanarYCbCrImage* videoImage = v->mImage->AsPlanarYCbCrImage();
|
||||
MOZ_ASSERT(videoImage);
|
||||
|
||||
if (!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */)) {
|
||||
// TODO: VideoData::SetVideoDataToImage may return NULL on non out-of-memory
|
||||
// failures.
|
||||
return Err(MediaResult(NS_ERROR_OUT_OF_MEMORY,
|
||||
"Failed to create a PlanarYCbCrImage"));
|
||||
if (MediaResult r = VideoData::SetVideoDataToImage(
|
||||
videoImage, aInfo, aBuffer, aPicture, true /* aCopyData */);
|
||||
NS_FAILED(r)) {
|
||||
return Err(r);
|
||||
}
|
||||
|
||||
perfRecorder.Record();
|
||||
|
@ -520,10 +520,11 @@ class VideoData : public MediaData {
|
||||
|
||||
// Initialize PlanarYCbCrImage. Only When aCopyData is true,
|
||||
// video data is copied to PlanarYCbCrImage.
|
||||
static bool SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
const VideoInfo& aInfo,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
const IntRect& aPicture, bool aCopyData);
|
||||
static MediaResult SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
const VideoInfo& aInfo,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
const IntRect& aPicture,
|
||||
bool aCopyData);
|
||||
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user