OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BITSTREAM_BUFFER_H_ | 5 #ifndef MEDIA_BASE_BITSTREAM_BUFFER_H_ |
6 #define MEDIA_BASE_BITSTREAM_BUFFER_H_ | 6 #define MEDIA_BASE_BITSTREAM_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "ipc/ipc_param_traits.h" |
14 #include "media/base/decrypt_config.h" | 15 #include "media/base/decrypt_config.h" |
15 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
16 #include "media/base/timestamp_constants.h" | 17 #include "media/base/timestamp_constants.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 // Class for passing bitstream buffers around. Does not take ownership of the | 21 // Class for passing bitstream buffers around. Does not take ownership of the |
21 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. | 22 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. |
22 class MEDIA_EXPORT BitstreamBuffer { | 23 class MEDIA_EXPORT BitstreamBuffer { |
23 public: | 24 public: |
| 25 BitstreamBuffer(); |
| 26 |
24 BitstreamBuffer(int32_t id, base::SharedMemoryHandle handle, size_t size); | 27 BitstreamBuffer(int32_t id, base::SharedMemoryHandle handle, size_t size); |
25 | 28 |
26 BitstreamBuffer(int32_t id, | 29 BitstreamBuffer(int32_t id, |
27 base::SharedMemoryHandle handle, | 30 base::SharedMemoryHandle handle, |
28 size_t size, | 31 size_t size, |
29 base::TimeDelta presentation_timestamp); | 32 base::TimeDelta presentation_timestamp); |
30 | 33 |
31 BitstreamBuffer(const BitstreamBuffer& other); | 34 BitstreamBuffer(const BitstreamBuffer& other); |
32 | 35 |
33 ~BitstreamBuffer(); | 36 ~BitstreamBuffer(); |
34 | 37 |
35 void SetDecryptConfig(const DecryptConfig& decrypt_config); | 38 void SetDecryptConfig(const DecryptConfig& decrypt_config); |
36 | 39 |
37 int32_t id() const { return id_; } | 40 int32_t id() const { return id_; } |
38 base::SharedMemoryHandle handle() const { return handle_; } | 41 base::SharedMemoryHandle handle() const { return handle_; } |
39 size_t size() const { return size_; } | 42 size_t size() const { return size_; } |
40 | 43 |
| 44 void set_handle(const base::SharedMemoryHandle& handle) { handle_ = handle; } |
| 45 |
41 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. | 46 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. |
42 base::TimeDelta presentation_timestamp() const { | 47 base::TimeDelta presentation_timestamp() const { |
43 return presentation_timestamp_; | 48 return presentation_timestamp_; |
44 } | 49 } |
45 | 50 |
46 // The following methods come from DecryptConfig. | 51 // The following methods come from DecryptConfig. |
47 | 52 |
48 const std::string& key_id() const { return key_id_; } | 53 const std::string& key_id() const { return key_id_; } |
49 const std::string& iv() const { return iv_; } | 54 const std::string& iv() const { return iv_; } |
50 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } | 55 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } |
51 | 56 |
52 private: | 57 private: |
53 int32_t id_; | 58 int32_t id_; |
54 base::SharedMemoryHandle handle_; | 59 base::SharedMemoryHandle handle_; |
55 size_t size_; | 60 size_t size_; |
56 | 61 |
57 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator | 62 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator |
58 // needs the timestamp because the underlying decoder may require it to | 63 // needs the timestamp because the underlying decoder may require it to |
59 // determine the output order. | 64 // determine the output order. |
60 base::TimeDelta presentation_timestamp_; | 65 base::TimeDelta presentation_timestamp_; |
61 | 66 |
62 // The following fields come from DecryptConfig. | 67 // The following fields come from DecryptConfig. |
63 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as | 68 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as |
64 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. | 69 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. |
65 | 70 |
66 std::string key_id_; // key ID. | 71 std::string key_id_; // key ID. |
67 std::string iv_; // initialization vector | 72 std::string iv_; // initialization vector |
68 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes | 73 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes |
69 | 74 |
| 75 friend struct IPC::ParamTraits<media::BitstreamBuffer>; |
| 76 |
70 // Allow compiler-generated copy & assign constructors. | 77 // Allow compiler-generated copy & assign constructors. |
71 }; | 78 }; |
72 | 79 |
73 } // namespace media | 80 } // namespace media |
74 | 81 |
75 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ | 82 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ |
OLD | NEW |