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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client, | 30 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client, |
31 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) final; | 31 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) final; |
32 void Initialize(mojom::VideoDecoderConfigPtr config, | 32 void Initialize(mojom::VideoDecoderConfigPtr config, |
33 bool low_delay, | 33 bool low_delay, |
34 const InitializeCallback& callback) final; | 34 const InitializeCallback& callback) final; |
35 void Decode(mojom::DecoderBufferPtr buffer, | 35 void Decode(mojom::DecoderBufferPtr buffer, |
36 const DecodeCallback& callback) final; | 36 const DecodeCallback& callback) final; |
37 void Reset(const ResetCallback& callback) final; | 37 void Reset(const ResetCallback& callback) final; |
38 | 38 |
39 private: | 39 private: |
| 40 // Helper methods so that we can bind them with a weak pointer to avoid |
| 41 // running mojom::VideoDecoder callbacks after connection error happens and |
| 42 // |this| is deleted. It's not safe to run the callbacks after a connection |
| 43 // error. |
40 void OnDecoderInitialized(const InitializeCallback& callback, bool success); | 44 void OnDecoderInitialized(const InitializeCallback& callback, bool success); |
41 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); | 45 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); |
| 46 void OnDecoderReset(const ResetCallback& callback); |
| 47 |
42 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); | 48 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); |
43 void OnDecoderReset(const ResetCallback& callback); | |
44 | 49 |
45 mojom::VideoDecoderClientAssociatedPtr client_; | 50 mojom::VideoDecoderClientAssociatedPtr client_; |
46 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 51 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
47 | 52 |
48 MojoMediaClient* mojo_media_client_; | 53 MojoMediaClient* mojo_media_client_; |
49 std::unique_ptr<media::VideoDecoder> decoder_; | 54 std::unique_ptr<media::VideoDecoder> decoder_; |
50 | 55 |
51 base::WeakPtr<MojoVideoDecoderService> weak_this_; | 56 base::WeakPtr<MojoVideoDecoderService> weak_this_; |
52 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; | 57 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; |
53 | 58 |
54 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); | 59 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); |
55 }; | 60 }; |
56 | 61 |
57 } // namespace media | 62 } // namespace media |
58 | 63 |
59 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ | 64 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ |
OLD | NEW |