nsresult ChannelMediaDecoder::Load(BaseMediaResource* aOriginal) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!mResource); AbstractThread::AutoEnter context(AbstractMainThread()); mResource = aOriginal->CloneData(mResourceCallback); if (!mResource) { return NS_ERROR_FAILURE; } DDLINKCHILD("resource", mResource.get()); nsresult rv = MediaShutdownManager::Instance().Register(this); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } SetStateMachine(CreateStateMachine()); NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE); GetStateMachine()->DispatchIsLiveStream(mResource->IsLiveStream()); return InitializeStateMachine(); }
nsresult ChannelMediaDecoder::Load(nsIChannel* aChannel, bool aIsPrivateBrowsing, nsIStreamListener** aStreamListener) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!mResource); MOZ_ASSERT(aStreamListener); AbstractThread::AutoEnter context(AbstractMainThread()); mResource = BaseMediaResource::Create(mResourceCallback, aChannel, aIsPrivateBrowsing); if (!mResource) { return NS_ERROR_FAILURE; } DDLINKCHILD("resource", mResource.get()); nsresult rv = MediaShutdownManager::Instance().Register(this); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } rv = mResource->Open(aStreamListener); NS_ENSURE_SUCCESS(rv, rv); SetStateMachine(CreateStateMachine()); NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE); GetStateMachine()->DispatchIsLiveStream(mResource->IsLiveStream()); return InitializeStateMachine(); }
ResourceStream::ResourceStream(mozilla::MediaResource* aResource) : mResource(aResource) , mPinCount(0) { MOZ_ASSERT(aResource); DDLINKCHILD("resource", &mResource); }
MP4Metadata::MP4Metadata(ByteStream* aSource) : mSource(aSource), mSourceAdaptor(aSource) { DDLINKCHILD("source", aSource); Mp4parseIo io = {read_source, &mSourceAdaptor}; mParser.reset(mp4parse_new(&io)); MOZ_ASSERT(mParser); }
MediaResult H264Converter::CreateDecoder(const VideoInfo& aConfig, DecoderDoctorDiagnostics* aDiagnostics) { if (!H264::HasSPS(aConfig.mExtraData)) { // nothing found yet, will try again later return NS_ERROR_NOT_INITIALIZED; } UpdateConfigFromExtraData(aConfig.mExtraData); SPSData spsdata; if (H264::DecodeSPSFromExtraData(aConfig.mExtraData, spsdata)) { // Do some format check here. // WMF H.264 Video Decoder and Apple ATDecoder do not support YUV444 format. if (spsdata.profile_idc == 244 /* Hi444PP */ || spsdata.chroma_format_idc == PDMFactory::kYUV444) { if (aDiagnostics) { aDiagnostics->SetVideoNotSupported(); } return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("No support for YUV444 format.")); } } else { return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Invalid SPS NAL.")); } MediaResult error = NS_OK; mDecoder = mPDM->CreateVideoDecoder({ aConfig, mTaskQueue, aDiagnostics, mImageContainer, mKnowsCompositor, mGMPCrashHelper, mType, mOnWaitingForKeyEvent, mDecoderOptions, mRate, &error }); if (!mDecoder) { if (NS_FAILED(error)) { // The decoder supports CreateDecoderParam::mError, returns the value. return error; } else { return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Unable to create H264 decoder")); } } DDLINKCHILD("decoder", mDecoder.get()); mNeedKeyframe = true; return NS_OK; }
already_AddRefed<SourceBuffer> MediaSource::AddSourceBuffer(const nsAString& aType, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); DecoderDoctorDiagnostics diagnostics; nsresult rv = IsTypeSupported(aType, &diagnostics); diagnostics.StoreFormatDiagnostics(GetOwner() ? GetOwner()->GetExtantDoc() : nullptr, aType, NS_SUCCEEDED(rv), __func__); MSE_API("AddSourceBuffer(aType=%s)%s", NS_ConvertUTF16toUTF8(aType).get(), rv == NS_OK ? "" : " [not supported]"); if (NS_FAILED(rv)) { aRv.Throw(rv); return nullptr; } if (mSourceBuffers->Length() >= MAX_SOURCE_BUFFERS) { aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR); return nullptr; } if (mReadyState != MediaSourceReadyState::Open) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } Maybe<MediaContainerType> containerType = MakeMediaContainerType(aType); if (!containerType) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return nullptr; } RefPtr<SourceBuffer> sourceBuffer = new SourceBuffer(this, *containerType); if (!sourceBuffer) { aRv.Throw(NS_ERROR_FAILURE); // XXX need a better error here return nullptr; } mSourceBuffers->Append(sourceBuffer); DDLINKCHILD("sourcebuffer[]", sourceBuffer.get()); MSE_DEBUG("sourceBuffer=%p", sourceBuffer.get()); return sourceBuffer.forget(); }
explicit BlockingStream(ByteStream* aStream) : mStream(aStream) { DDLINKCHILD("stream", aStream); }