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_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "media/base/decode_status.h" | 12 #include "media/base/decode_status.h" |
13 #include "media/mojo/interfaces/video_decoder.mojom.h" | 13 #include "media/mojo/interfaces/video_decoder.mojom.h" |
14 #include "mojo/public/cpp/bindings/strong_binding.h" | |
15 | 14 |
16 namespace media { | 15 namespace media { |
17 | 16 |
18 class MojoDecoderBufferReader; | 17 class MojoDecoderBufferReader; |
19 class MojoMediaClient; | 18 class MojoMediaClient; |
20 class VideoDecoder; | 19 class VideoDecoder; |
21 class VideoFrame; | 20 class VideoFrame; |
22 | 21 |
23 // Implementation of a mojom::VideoDecoder which runs in the GPU process, | 22 // Implementation of a mojom::VideoDecoder which runs in the GPU process, |
24 // and wraps a media::VideoDecoder. | 23 // and wraps a media::VideoDecoder. |
25 class MojoVideoDecoderService : public mojom::VideoDecoder { | 24 class MojoVideoDecoderService : public mojom::VideoDecoder { |
26 public: | 25 public: |
27 MojoVideoDecoderService(mojo::InterfaceRequest<mojom::VideoDecoder> request, | 26 explicit MojoVideoDecoderService(MojoMediaClient* mojo_media_client); |
28 MojoMediaClient* mojo_media_client); | |
29 ~MojoVideoDecoderService() final; | 27 ~MojoVideoDecoderService() final; |
30 | 28 |
31 // mojom::VideoDecoder implementation | 29 // mojom::VideoDecoder implementation |
32 void Construct(mojom::VideoDecoderClientPtr client, | 30 void Construct(mojom::VideoDecoderClientPtr client, |
33 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) final; | 31 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) final; |
34 void Initialize(mojom::VideoDecoderConfigPtr config, | 32 void Initialize(mojom::VideoDecoderConfigPtr config, |
35 bool low_delay, | 33 bool low_delay, |
36 const InitializeCallback& callback) final; | 34 const InitializeCallback& callback) final; |
37 void Decode(mojom::DecoderBufferPtr buffer, | 35 void Decode(mojom::DecoderBufferPtr buffer, |
38 const DecodeCallback& callback) final; | 36 const DecodeCallback& callback) final; |
39 void Reset(const ResetCallback& callback) final; | 37 void Reset(const ResetCallback& callback) final; |
40 | 38 |
41 private: | 39 private: |
42 void OnDecoderInitialized(const InitializeCallback& callback, bool success); | 40 void OnDecoderInitialized(const InitializeCallback& callback, bool success); |
43 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); | 41 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); |
44 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); | 42 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); |
45 void OnDecoderReset(const ResetCallback& callback); | 43 void OnDecoderReset(const ResetCallback& callback); |
46 | 44 |
47 mojo::StrongBinding<mojom::VideoDecoder> binding_; | |
48 mojom::VideoDecoderClientPtr client_; | 45 mojom::VideoDecoderClientPtr client_; |
49 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 46 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
50 | 47 |
51 MojoMediaClient* mojo_media_client_; | 48 MojoMediaClient* mojo_media_client_; |
52 std::unique_ptr<media::VideoDecoder> decoder_; | 49 std::unique_ptr<media::VideoDecoder> decoder_; |
53 | 50 |
54 base::WeakPtr<MojoVideoDecoderService> weak_this_; | 51 base::WeakPtr<MojoVideoDecoderService> weak_this_; |
55 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; | 52 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; |
56 | 53 |
57 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); | 54 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); |
58 }; | 55 }; |
59 | 56 |
60 } // namespace media | 57 } // namespace media |
61 | 58 |
62 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ | 59 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ |
OLD | NEW |