OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "media/base/video_decoder.h" | 10 #include "media/base/video_decoder.h" |
| 11 #include "media/mojo/interfaces/video_decoder.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "mojo/public/cpp/system/data_pipe.h" |
11 | 14 |
12 namespace base { | 15 namespace base { |
13 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
14 } | 17 } |
15 | 18 |
16 namespace media { | 19 namespace media { |
17 | 20 |
| 21 class GpuVideoAcceleratorFactories; |
| 22 |
18 // A VideoDecoder that proxies to an interfaces::VideoDecoder. | 23 // A VideoDecoder that proxies to an interfaces::VideoDecoder. |
19 class MojoVideoDecoder : public VideoDecoder { | 24 class MojoVideoDecoder : public VideoDecoder, |
| 25 public interfaces::VideoDecoderClient { |
20 public: | 26 public: |
21 MojoVideoDecoder(); | 27 MojoVideoDecoder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 28 GpuVideoAcceleratorFactories* gpu_factories, |
| 29 interfaces::VideoDecoderPtr remote_decoder); |
22 ~MojoVideoDecoder() final; | 30 ~MojoVideoDecoder() final; |
23 | 31 |
24 // VideoDecoder implementation. | 32 // VideoDecoder implementation. |
25 std::string GetDisplayName() const final; | 33 std::string GetDisplayName() const final; |
26 void Initialize(const VideoDecoderConfig& config, | 34 void Initialize(const VideoDecoderConfig& config, |
27 bool low_delay, | 35 bool low_delay, |
28 CdmContext* cdm_context, | 36 CdmContext* cdm_context, |
29 const InitCB& init_cb, | 37 const InitCB& init_cb, |
30 const OutputCB& output_cb) final; | 38 const OutputCB& output_cb) final; |
31 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 39 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
32 const DecodeCB& decode_cb) final; | 40 const DecodeCB& decode_cb) final; |
33 void Reset(const base::Closure& closure) final; | 41 void Reset(const base::Closure& closure) final; |
34 bool NeedsBitstreamConversion() const final; | 42 bool NeedsBitstreamConversion() const final; |
35 bool CanReadWithoutStalling() const final; | 43 bool CanReadWithoutStalling() const final; |
36 int GetMaxDecodeRequests() const final; | 44 int GetMaxDecodeRequests() const final; |
37 | 45 |
| 46 // interfaces::VideoDecoderClient implementation. |
| 47 void OnVideoFrameDecoded(interfaces::VideoFramePtr frame) final; |
| 48 |
38 private: | 49 private: |
| 50 void OnInitializeDone(bool status); |
| 51 void OnDecodeDone(interfaces::DecodeStatus status); |
| 52 void OnResetDone(); |
| 53 |
| 54 void BindRemoteDecoder(); |
| 55 void OnConnectionError(); |
| 56 |
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 58 GpuVideoAcceleratorFactories* gpu_factories_; |
| 59 |
| 60 // Used to pass the remote decoder from the constructor (on the main thread) |
| 61 // to Initialize() (on the media thread). |
| 62 interfaces::VideoDecoderPtrInfo remote_decoder_info_; |
| 63 |
| 64 InitCB init_cb_; |
| 65 OutputCB output_cb_; |
| 66 DecodeCB decode_cb_; |
| 67 base::Closure reset_cb_; |
| 68 |
| 69 interfaces::VideoDecoderPtr remote_decoder_; |
| 70 mojo::ScopedDataPipeProducerHandle decoder_buffer_pipe_; |
| 71 bool remote_decoder_bound_ = false; |
| 72 bool has_connection_error_ = false; |
| 73 mojo::Binding<VideoDecoderClient> binding_; |
40 | 74 |
41 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoder); | 75 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoder); |
42 }; | 76 }; |
43 | 77 |
44 } // namespace media | 78 } // namespace media |
45 | 79 |
46 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ | 80 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_H_ |
OLD | NEW |