Bug 862182 - Hold references to MediaResource in nsRefPtrs (content/media/omx), and fix some omx compiler warnings. r=doublec

This commit is contained in:
Chris Pearce 2013-05-01 11:23:46 +12:00
Родитель 8dccc1d8a8
Коммит 601260f1a0
4 изменённых файлов: 14 добавлений и 18 удалений

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

@ -22,7 +22,6 @@ struct VideoPlane {
struct VideoFrame { struct VideoFrame {
int64_t mTimeUs; int64_t mTimeUs;
int64_t mEndTimeUs;
bool mKeyFrame; bool mKeyFrame;
bool mShouldSkip; bool mShouldSkip;
void *mData; void *mData;

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

@ -43,7 +43,7 @@ nsresult MediaOmxReader::Init(MediaDecoderReader* aCloneDonor)
} }
nsresult MediaOmxReader::ReadMetadata(VideoInfo* aInfo, nsresult MediaOmxReader::ReadMetadata(VideoInfo* aInfo,
MetadataTags** aTags) MetadataTags** aTags)
{ {
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
@ -118,7 +118,7 @@ nsresult MediaOmxReader::ResetDecode()
} }
bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip, bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
int64_t aTimeThreshold) int64_t aTimeThreshold)
{ {
// Record number of frames decoded and parsed. Automatically update the // Record number of frames decoded and parsed. Automatically update the
// stats counters using the AutoNotifyDecoded stack-based class. // stats counters using the AutoNotifyDecoded stack-based class.
@ -339,7 +339,7 @@ void MediaOmxReader::OnDecodeThreadFinish() {
void MediaOmxReader::OnDecodeThreadStart() { void MediaOmxReader::OnDecodeThreadStart() {
if (mOmxDecoder.get()) { if (mOmxDecoder.get()) {
nsresult result = mOmxDecoder->Play(); DebugOnly<nsresult> result = mOmxDecoder->Play();
NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding"); NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding");
} }
} }

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

@ -39,8 +39,8 @@ VideoGraphicBuffer::VideoGraphicBuffer(const android::wp<android::OmxDecoder> aO
android::MediaBuffer *aBuffer, android::MediaBuffer *aBuffer,
SurfaceDescriptor *aDescriptor) SurfaceDescriptor *aDescriptor)
: GraphicBufferLocked(*aDescriptor), : GraphicBufferLocked(*aDescriptor),
mOmxDecoder(aOmxDecoder), mMediaBuffer(aBuffer),
mMediaBuffer(aBuffer) mOmxDecoder(aOmxDecoder)
{ {
mMediaBuffer->add_ref(); mMediaBuffer->add_ref();
} }
@ -74,7 +74,7 @@ namespace android {
MediaStreamSource::MediaStreamSource(MediaResource *aResource, MediaStreamSource::MediaStreamSource(MediaResource *aResource,
AbstractMediaDecoder *aDecoder) : AbstractMediaDecoder *aDecoder) :
mDecoder(aDecoder), mResource(aResource) mResource(aResource), mDecoder(aDecoder)
{ {
} }
@ -127,8 +127,8 @@ using namespace android;
OmxDecoder::OmxDecoder(MediaResource *aResource, OmxDecoder::OmxDecoder(MediaResource *aResource,
AbstractMediaDecoder *aDecoder) : AbstractMediaDecoder *aDecoder) :
mResource(aResource),
mDecoder(aDecoder), mDecoder(aDecoder),
mResource(aResource),
mVideoWidth(0), mVideoWidth(0),
mVideoHeight(0), mVideoHeight(0),
mVideoColorFormat(0), mVideoColorFormat(0),
@ -141,8 +141,8 @@ OmxDecoder::OmxDecoder(MediaResource *aResource,
mVideoBuffer(nullptr), mVideoBuffer(nullptr),
mAudioBuffer(nullptr), mAudioBuffer(nullptr),
mIsVideoSeeking(false), mIsVideoSeeking(false),
mPaused(false), mAudioMetadataRead(false),
mAudioMetadataRead(false) mPaused(false)
{ {
} }
@ -234,7 +234,7 @@ bool OmxDecoder::Init() {
// OMXClient::connect() always returns OK and abort's fatally if // OMXClient::connect() always returns OK and abort's fatally if
// it can't connect. // it can't connect.
OMXClient client; OMXClient client;
status_t err = client.connect(); DebugOnly<status_t> err = client.connect();
NS_ASSERTION(err == OK, "Failed to connect to OMX in mediaserver."); NS_ASSERTION(err == OK, "Failed to connect to OMX in mediaserver.");
sp<IOMX> omx = client.interface(); sp<IOMX> omx = client.interface();
@ -512,7 +512,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
if (err == OK && mVideoBuffer->range_length() > 0) { if (err == OK && mVideoBuffer->range_length() > 0) {
int64_t timeUs; int64_t timeUs;
int64_t durationUs;
int32_t unreadable; int32_t unreadable;
int32_t keyFrame; int32_t keyFrame;
@ -545,7 +544,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
aFrame->mGraphicBuffer = new mozilla::layers::VideoGraphicBuffer(this, mVideoBuffer, &newDescriptor); aFrame->mGraphicBuffer = new mozilla::layers::VideoGraphicBuffer(this, mVideoBuffer, &newDescriptor);
aFrame->mRotation = mVideoRotation; aFrame->mRotation = mVideoRotation;
aFrame->mTimeUs = timeUs; aFrame->mTimeUs = timeUs;
aFrame->mEndTimeUs = timeUs + durationUs;
aFrame->mKeyFrame = keyFrame; aFrame->mKeyFrame = keyFrame;
aFrame->Y.mWidth = mVideoWidth; aFrame->Y.mWidth = mVideoWidth;
aFrame->Y.mHeight = mVideoHeight; aFrame->Y.mHeight = mVideoHeight;
@ -560,8 +558,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
if (!ToVideoFrame(aFrame, timeUs, data, length, keyFrame)) { if (!ToVideoFrame(aFrame, timeUs, data, length, keyFrame)) {
return false; return false;
} }
aFrame->mEndTimeUs = timeUs + durationUs;
} }
if (aKeyframeSkip && timeUs < aTimeUs) { if (aKeyframeSkip && timeUs < aTimeUs) {
@ -696,3 +692,4 @@ void OmxDecoder::Pause() {
} }
mPaused = true; mPaused = true;
} }

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

@ -38,10 +38,10 @@ class MediaStreamSource : public DataSource {
typedef mozilla::MediaResource MediaResource; typedef mozilla::MediaResource MediaResource;
typedef mozilla::AbstractMediaDecoder AbstractMediaDecoder; typedef mozilla::AbstractMediaDecoder AbstractMediaDecoder;
MediaResource *mResource; nsRefPtr<MediaResource> mResource;
AbstractMediaDecoder *mDecoder; AbstractMediaDecoder *mDecoder;
public: public:
MediaStreamSource(MediaResource *aResource, MediaStreamSource(MediaResource* aResource,
AbstractMediaDecoder *aDecoder); AbstractMediaDecoder *aDecoder);
virtual status_t initCheck() const; virtual status_t initCheck() const;
@ -80,7 +80,7 @@ class OmxDecoder : public RefBase {
}; };
AbstractMediaDecoder *mDecoder; AbstractMediaDecoder *mDecoder;
MediaResource *mResource; nsRefPtr<MediaResource> mResource;
sp<GonkNativeWindow> mNativeWindow; sp<GonkNativeWindow> mNativeWindow;
sp<GonkNativeWindowClient> mNativeWindowClient; sp<GonkNativeWindowClient> mNativeWindowClient;
sp<MediaSource> mVideoTrack; sp<MediaSource> mVideoTrack;