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 | 14 |
| 15 namespace gpu { |
| 16 struct SyncToken; |
| 17 }; |
| 18 |
15 namespace media { | 19 namespace media { |
16 | 20 |
17 class DecoderBuffer; | 21 class DecoderBuffer; |
18 class MojoDecoderBufferReader; | 22 class MojoDecoderBufferReader; |
19 class MojoMediaClient; | 23 class MojoMediaClient; |
20 class VideoDecoder; | 24 class VideoDecoder; |
21 class VideoFrame; | 25 class VideoFrame; |
22 | 26 |
23 // Implementation of a mojom::VideoDecoder which runs in the GPU process, | 27 // Implementation of a mojom::VideoDecoder which runs in the GPU process, |
24 // and wraps a media::VideoDecoder. | 28 // and wraps a media::VideoDecoder. |
25 class MojoVideoDecoderService : public mojom::VideoDecoder { | 29 class MojoVideoDecoderService : public mojom::VideoDecoder { |
26 public: | 30 public: |
27 explicit MojoVideoDecoderService(MojoMediaClient* mojo_media_client); | 31 explicit MojoVideoDecoderService(MojoMediaClient* mojo_media_client); |
28 ~MojoVideoDecoderService() final; | 32 ~MojoVideoDecoderService() final; |
29 | 33 |
30 // mojom::VideoDecoder implementation | 34 // mojom::VideoDecoder implementation |
31 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client, | 35 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client, |
32 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe, | 36 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe, |
33 mojom::CommandBufferIdPtr command_buffer_id) final; | 37 mojom::CommandBufferIdPtr command_buffer_id) final; |
34 void Initialize(mojom::VideoDecoderConfigPtr config, | 38 void Initialize(mojom::VideoDecoderConfigPtr config, |
35 bool low_delay, | 39 bool low_delay, |
36 const InitializeCallback& callback) final; | 40 const InitializeCallback& callback) final; |
37 void Decode(mojom::DecoderBufferPtr buffer, | 41 void Decode(mojom::DecoderBufferPtr buffer, |
38 const DecodeCallback& callback) final; | 42 const DecodeCallback& callback) final; |
39 void Reset(const ResetCallback& callback) final; | 43 void Reset(const ResetCallback& callback) final; |
| 44 void OnReleaseMailbox(const base::UnguessableToken& release_token, |
| 45 const gpu::SyncToken& release_sync_token) final; |
40 | 46 |
41 private: | 47 private: |
42 // Helper methods so that we can bind them with a weak pointer to avoid | 48 // Helper methods so that we can bind them with a weak pointer to avoid |
43 // running mojom::VideoDecoder callbacks after connection error happens and | 49 // running mojom::VideoDecoder callbacks after connection error happens and |
44 // |this| is deleted. It's not safe to run the callbacks after a connection | 50 // |this| is deleted. It's not safe to run the callbacks after a connection |
45 // error. | 51 // error. |
46 void OnDecoderInitialized(const InitializeCallback& callback, bool success); | 52 void OnDecoderInitialized(const InitializeCallback& callback, bool success); |
47 void OnDecoderRead(const DecodeCallback& callback, | 53 void OnDecoderRead(const DecodeCallback& callback, |
48 scoped_refptr<DecoderBuffer> buffer); | 54 scoped_refptr<DecoderBuffer> buffer); |
49 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); | 55 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); |
50 void OnDecoderReset(const ResetCallback& callback); | 56 void OnDecoderReset(const ResetCallback& callback); |
51 | 57 |
52 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); | 58 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); |
53 | 59 |
54 mojom::VideoDecoderClientAssociatedPtr client_; | 60 mojom::VideoDecoderClientAssociatedPtr client_; |
55 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 61 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
56 | 62 |
57 MojoMediaClient* mojo_media_client_; | 63 MojoMediaClient* mojo_media_client_; |
58 std::unique_ptr<media::VideoDecoder> decoder_; | 64 std::unique_ptr<media::VideoDecoder> decoder_; |
59 | 65 |
60 base::WeakPtr<MojoVideoDecoderService> weak_this_; | 66 base::WeakPtr<MojoVideoDecoderService> weak_this_; |
61 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; | 67 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; |
62 | 68 |
63 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); | 69 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); |
64 }; | 70 }; |
65 | 71 |
66 } // namespace media | 72 } // namespace media |
67 | 73 |
68 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ | 74 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ |
OLD | NEW |