Bug 1685215 - 'AdjustForStartTime()' should only exist on decoded data type. r=padenot

`AdjustForStartTime()` is only used for decoded data type in order to adjust their start time to zero, such as `VideoData` and `AudioData`.

However, some other types inherited from `MediaData` don't need that function. Eg. `MediaRawData`, so it's not necessary to put it on the `MediaData`, we should move that function to `VideoData` and `AudioData` separately.

Differential Revision: https://phabricator.services.mozilla.com/D100846
This commit is contained in:
alwu 2021-01-11 08:13:12 +00:00
parent c2db81c2b7
commit b8c6ef7b92
2 changed files with 18 additions and 12 deletions

View File

@ -53,10 +53,14 @@ Span<AudioDataValue> AudioData::Data() const {
bool AudioData::AdjustForStartTime(const media::TimeUnit& aStartTime) {
mOriginalTime -= aStartTime;
mTime -= aStartTime;
if (mTrimWindow) {
*mTrimWindow -= aStartTime;
}
return MediaData::AdjustForStartTime(aStartTime) && mOriginalTime.IsValid();
if (mTime.IsNegative()) {
NS_WARNING("Negative audio start time after time-adjustment!");
}
return mTime.IsValid() && mOriginalTime.IsValid();
}
bool AudioData::SetTrimWindow(const media::TimeInterval& aTrim) {
@ -233,6 +237,14 @@ void VideoData::UpdateTimestamp(const TimeUnit& aTimestamp) {
mDuration = updatedDuration;
}
bool VideoData::AdjustForStartTime(const media::TimeUnit& aStartTime) {
mTime -= aStartTime;
if (mTime.IsNegative()) {
NS_WARNING("Negative video start time after time-adjustment!");
}
return mTime.IsValid();
}
PlanarYCbCrData ConstructPlanarYCbCrData(const VideoInfo& aInfo,
const VideoData::YCbCrBuffer& aBuffer,
const IntRect& aPicture) {

View File

@ -308,16 +308,6 @@ class MediaData {
GetEndTime().IsValid() && GetEndTimecode().IsValid();
}
// Return true if the adjusted time is valid. Caller should handle error when
// the result is invalid.
virtual bool AdjustForStartTime(const media::TimeUnit& aStartTime) {
mTime -= aStartTime;
if (mTime.IsNegative()) {
NS_WARNING("Negative start time after time-adjustment!");
}
return mTime.IsValid();
}
template <typename ReturnType>
const ReturnType* As() const {
MOZ_ASSERT(this->mType == ReturnType::sType);
@ -382,7 +372,7 @@ class AudioData : public MediaData {
// Return true if the adjusted time is valid. Caller should handle error when
// the result is invalid.
bool AdjustForStartTime(const media::TimeUnit& aStartTime) override;
bool AdjustForStartTime(const media::TimeUnit& aStartTime);
const uint32_t mChannels;
// The AudioConfig::ChannelLayout map. Channels are ordered as per SMPTE
@ -512,6 +502,10 @@ class VideoData : public MediaData {
void UpdateDuration(const media::TimeUnit& aDuration);
void UpdateTimestamp(const media::TimeUnit& aTimestamp);
// Return true if the adjusted time is valid. Caller should handle error when
// the result is invalid.
bool AdjustForStartTime(const media::TimeUnit& aStartTime);
void SetNextKeyFrameTime(const media::TimeUnit& aTime) {
mNextKeyFrameTime = aTime;
}