Commit 9fa42c24 authored by mcasas's avatar mcasas Committed by Commit bot

RTCVideoDecoder: add Destroy() static method for RTCVideoDecoderFactory

RTCVDFactory does not know where RTCVideoDecoder is created (it is
created in one of the parameter's task runner), however it knows
where to destroy it. Address this imbalance by offering an
RTCVideoDecoder::Destroy() where the threading is explicit, since
it lives next to RTCVideoDecoder::Create().

BUG=554737
TEST= tiny change, all unit tests passing.

Review URL: https://codereview.chromium.org/1458683002

Cr-Commit-Position: refs/heads/master@{#360606}
parent 59eb48a7
......@@ -116,6 +116,12 @@ scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create(
return decoder.Pass();
}
// static
void RTCVideoDecoder::Destroy(webrtc::VideoDecoder* decoder,
media::GpuVideoAcceleratorFactories* factories) {
factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder);
}
int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings,
int32_t /*numberOfCores*/) {
DVLOG(2) << "InitDecode";
......
......@@ -51,11 +51,14 @@ class CONTENT_EXPORT RTCVideoDecoder
public:
~RTCVideoDecoder() override;
// Creates a RTCVideoDecoder. Returns NULL if failed. The video decoder will
// run on the message loop of |factories|.
// Creates a RTCVideoDecoder on the message loop of |factories|. Returns NULL
// if failed. The video decoder will run on the message loop of |factories|.
static scoped_ptr<RTCVideoDecoder> Create(
webrtc::VideoCodecType type,
media::GpuVideoAcceleratorFactories* factories);
// Destroys |decoder| on the loop of |factories|
static void Destroy(webrtc::VideoDecoder* decoder,
media::GpuVideoAcceleratorFactories* factories);
// webrtc::VideoDecoder implementation.
// Called on WebRTC DecodingThread.
......
......@@ -29,7 +29,7 @@ webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder(
void RTCVideoDecoderFactory::DestroyVideoDecoder(
webrtc::VideoDecoder* decoder) {
DVLOG(2) << __FUNCTION__;
gpu_factories_->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder);
RTCVideoDecoder::Destroy(decoder, gpu_factories_);
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment