Chromium Code Reviews| 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 "media/base/decrypt_config.h" | 14 #include "media/base/decrypt_config.h" |
| 15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 #include "media/base/timestamp_constants.h" | 16 #include "media/base/timestamp_constants.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 | 19 |
| 20 // Class for passing bitstream buffers around. Does not take ownership of the | 20 // Class for passing bitstream buffers around. Does not take ownership of the |
| 21 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. | 21 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. |
| 22 class MEDIA_EXPORT BitstreamBuffer { | 22 class MEDIA_EXPORT BitstreamBuffer { |
| 23 public: | 23 public: |
| 24 BitstreamBuffer(int32_t id, base::SharedMemoryHandle handle, size_t size); | 24 BitstreamBuffer(int32_t id, base::SharedMemoryHandle handle, size_t size); |
| 25 | 25 |
| 26 // Constructs a new BitstreamBuffer. The content of the bitstream is located | |
| 27 // at |offset| bytes away from the start of the shared memory and the payload | |
| 28 // is |size| bytes. | |
| 29 BitstreamBuffer(int32_t id, | |
| 30 base::SharedMemoryHandle handle, | |
| 31 size_t size, | |
| 32 off_t offset); | |
|
xhwang
2016/01/13 18:54:54
What's the default |presentation_timestamp| in thi
xhwang
2016/01/13 18:54:54
I never used off_t before. After a bit searching a
Owen Lin
2016/01/14 03:56:34
When the |presentation_timestamp| is not provided
Owen Lin
2016/01/14 03:56:34
This parameter is used to calculate the offset whe
| |
| 33 | |
| 26 BitstreamBuffer(int32_t id, | 34 BitstreamBuffer(int32_t id, |
| 27 base::SharedMemoryHandle handle, | 35 base::SharedMemoryHandle handle, |
| 28 size_t size, | 36 size_t size, |
| 29 base::TimeDelta presentation_timestamp); | 37 base::TimeDelta presentation_timestamp); |
| 30 | 38 |
| 39 BitstreamBuffer(int32_t id, | |
| 40 base::SharedMemoryHandle handle, | |
| 41 size_t size, | |
| 42 off_t offset, | |
| 43 base::TimeDelta presentation_timestamp); | |
| 44 | |
| 31 ~BitstreamBuffer(); | 45 ~BitstreamBuffer(); |
| 32 | 46 |
| 33 void SetDecryptConfig(const DecryptConfig& decrypt_config); | 47 void SetDecryptConfig(const DecryptConfig& decrypt_config); |
| 34 | 48 |
| 35 int32_t id() const { return id_; } | 49 int32_t id() const { return id_; } |
| 36 base::SharedMemoryHandle handle() const { return handle_; } | 50 base::SharedMemoryHandle handle() const { return handle_; } |
| 51 | |
| 52 // The number of bytes of the actual bitstream data. It is the size of the | |
| 53 // content instead of the whole shared memory. | |
| 37 size_t size() const { return size_; } | 54 size_t size() const { return size_; } |
| 38 | 55 |
| 56 // The offset to the start of actual bitstream data in the shared memory. | |
| 57 off_t offset() const { return offset_; } | |
| 58 | |
| 39 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. | 59 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. |
| 40 base::TimeDelta presentation_timestamp() const { | 60 base::TimeDelta presentation_timestamp() const { |
| 41 return presentation_timestamp_; | 61 return presentation_timestamp_; |
| 42 } | 62 } |
| 43 | 63 |
| 44 // The following methods come from DecryptConfig. | 64 // The following methods come from DecryptConfig. |
| 45 | 65 |
| 46 const std::string& key_id() const { return key_id_; } | 66 const std::string& key_id() const { return key_id_; } |
| 47 const std::string& iv() const { return iv_; } | 67 const std::string& iv() const { return iv_; } |
| 48 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } | 68 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } |
| 49 | 69 |
| 50 private: | 70 private: |
| 51 int32_t id_; | 71 int32_t id_; |
| 52 base::SharedMemoryHandle handle_; | 72 base::SharedMemoryHandle handle_; |
| 53 size_t size_; | 73 size_t size_; |
| 74 off_t offset_; | |
| 54 | 75 |
| 55 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator | 76 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator |
| 56 // needs the timestamp because the underlying decoder may require it to | 77 // needs the timestamp because the underlying decoder may require it to |
| 57 // determine the output order. | 78 // determine the output order. |
| 58 base::TimeDelta presentation_timestamp_; | 79 base::TimeDelta presentation_timestamp_; |
| 59 | 80 |
| 60 // The following fields come from DecryptConfig. | 81 // The following fields come from DecryptConfig. |
| 61 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as | 82 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as |
| 62 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. | 83 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. |
| 63 | 84 |
| 64 std::string key_id_; // key ID. | 85 std::string key_id_; // key ID. |
| 65 std::string iv_; // initialization vector | 86 std::string iv_; // initialization vector |
| 66 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes | 87 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes |
| 67 | 88 |
| 68 // Allow compiler-generated copy & assign constructors. | 89 // Allow compiler-generated copy & assign constructors. |
| 69 }; | 90 }; |
| 70 | 91 |
| 71 } // namespace media | 92 } // namespace media |
| 72 | 93 |
| 73 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ | 94 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ |
| OLD | NEW |