OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ |
6 #define MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ | 6 #define MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ |
7 | 7 |
8 #include <media/NdkMediaCodec.h> | 8 #include <media/NdkMediaCodec.h> |
| 9 #include <stdint.h> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "media/base/android/media_codec_bridge.h" | 14 #include "media/base/android/media_codec_bridge.h" |
14 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class MEDIA_EXPORT NdkMediaCodecBridge : public MediaCodecBridge { | 19 class MEDIA_EXPORT NdkMediaCodecBridge : public MediaCodecBridge { |
19 public: | 20 public: |
20 ~NdkMediaCodecBridge() override; | 21 ~NdkMediaCodecBridge() override; |
21 | 22 |
22 // MediaCodecBridge implementation. | 23 // MediaCodecBridge implementation. |
23 MediaCodecStatus Reset() override; | 24 MediaCodecStatus Reset() override; |
24 bool Start() override; | 25 bool Start() override; |
25 void Stop() override; | 26 void Stop() override; |
26 void GetOutputFormat(int* width, int* height) override; | 27 void GetOutputFormat(int* width, int* height) override; |
27 int GetOutputSamplingRate() override; | 28 int GetOutputSamplingRate() override; |
28 MediaCodecStatus QueueInputBuffer( | 29 MediaCodecStatus QueueInputBuffer( |
29 int index, | 30 int index, |
30 const uint8* data, | 31 const uint8_t* data, |
31 size_t data_size, | 32 size_t data_size, |
32 const base::TimeDelta& presentation_time) override; | 33 const base::TimeDelta& presentation_time) override; |
33 using MediaCodecBridge::QueueSecureInputBuffer; | 34 using MediaCodecBridge::QueueSecureInputBuffer; |
34 MediaCodecStatus QueueSecureInputBuffer( | 35 MediaCodecStatus QueueSecureInputBuffer( |
35 int index, | 36 int index, |
36 const uint8* data, | 37 const uint8_t* data, |
37 size_t data_size, | 38 size_t data_size, |
38 const std::vector<char>& key_id, | 39 const std::vector<char>& key_id, |
39 const std::vector<char>& iv, | 40 const std::vector<char>& iv, |
40 const SubsampleEntry* subsamples, | 41 const SubsampleEntry* subsamples, |
41 int subsamples_size, | 42 int subsamples_size, |
42 const base::TimeDelta& presentation_time) override; | 43 const base::TimeDelta& presentation_time) override; |
43 void QueueEOS(int input_buffer_index); | 44 void QueueEOS(int input_buffer_index); |
44 MediaCodecStatus DequeueInputBuffer(const base::TimeDelta& timeout, | 45 MediaCodecStatus DequeueInputBuffer(const base::TimeDelta& timeout, |
45 int* index) override; | 46 int* index) override; |
46 MediaCodecStatus DequeueOutputBuffer(const base::TimeDelta& timeout, | 47 MediaCodecStatus DequeueOutputBuffer(const base::TimeDelta& timeout, |
47 int* index, | 48 int* index, |
48 size_t* offset, | 49 size_t* offset, |
49 size_t* size, | 50 size_t* size, |
50 base::TimeDelta* presentation_time, | 51 base::TimeDelta* presentation_time, |
51 bool* end_of_stream, | 52 bool* end_of_stream, |
52 bool* key_frame) override; | 53 bool* key_frame) override; |
53 void ReleaseOutputBuffer(int index, bool render) override; | 54 void ReleaseOutputBuffer(int index, bool render) override; |
54 void GetInputBuffer(int input_buffer_index, | 55 void GetInputBuffer(int input_buffer_index, |
55 uint8** data, | 56 uint8_t** data, |
56 size_t* capacity) override; | 57 size_t* capacity) override; |
57 bool CopyFromOutputBuffer(int index, | 58 bool CopyFromOutputBuffer(int index, |
58 size_t offset, | 59 size_t offset, |
59 void* dst, | 60 void* dst, |
60 int dst_size) override; | 61 int dst_size) override; |
61 | 62 |
62 protected: | 63 protected: |
63 NdkMediaCodecBridge(const std::string& mime, | 64 NdkMediaCodecBridge(const std::string& mime, |
64 bool is_secure, | 65 bool is_secure, |
65 MediaCodecDirection direction); | 66 MediaCodecDirection direction); |
66 | 67 |
67 private: | 68 private: |
68 struct AMediaCodecDeleter { | 69 struct AMediaCodecDeleter { |
69 inline void operator()(AMediaCodec* ptr) const { AMediaCodec_delete(ptr); } | 70 inline void operator()(AMediaCodec* ptr) const { AMediaCodec_delete(ptr); } |
70 }; | 71 }; |
71 | 72 |
72 scoped_ptr<AMediaCodec, AMediaCodecDeleter> media_codec_; | 73 scoped_ptr<AMediaCodec, AMediaCodecDeleter> media_codec_; |
73 | 74 |
74 DISALLOW_COPY_AND_ASSIGN(NdkMediaCodecBridge); | 75 DISALLOW_COPY_AND_ASSIGN(NdkMediaCodecBridge); |
75 }; | 76 }; |
76 | 77 |
77 } // namespace media | 78 } // namespace media |
78 | 79 |
79 #endif // MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ | 80 #endif // MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_ |
OLD | NEW |