Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: media/base/bitstream_buffer.h

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address posciak's comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "media/base/decrypt_config.h" 11 #include "media/base/decrypt_config.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 #include "media/base/timestamp_constants.h" 13 #include "media/base/timestamp_constants.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 // Class for passing bitstream buffers around. Does not take ownership of the 17 // Class for passing bitstream buffers around. Does not take ownership of the
18 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. 18 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev.
19 class MEDIA_EXPORT BitstreamBuffer { 19 class MEDIA_EXPORT BitstreamBuffer {
20 public: 20 public:
21 BitstreamBuffer(int32 id, base::SharedMemoryHandle handle, size_t size); 21 BitstreamBuffer(int32 id, base::SharedMemoryHandle handle, size_t size);
22 22
23 // Constructs a new BitstreamBuffer. The content of the bitstream is located
24 // at |offset| bytes away from the start of the shared memory and the length
25 // is |size| bytes.
Pawel Osciak 2016/01/05 06:22:51 s/length/payload/
Owen Lin 2016/01/06 03:45:46 Done.
26 BitstreamBuffer(int32 id,
27 base::SharedMemoryHandle handle,
28 size_t size,
29 off_t offset);
30
23 BitstreamBuffer(int32 id, 31 BitstreamBuffer(int32 id,
24 base::SharedMemoryHandle handle, 32 base::SharedMemoryHandle handle,
25 size_t size, 33 size_t size,
26 base::TimeDelta presentation_timestamp); 34 base::TimeDelta presentation_timestamp);
27 35
36 BitstreamBuffer(int32 id,
37 base::SharedMemoryHandle handle,
38 size_t size,
39 off_t offset,
40 base::TimeDelta presentation_timestamp);
41
28 ~BitstreamBuffer(); 42 ~BitstreamBuffer();
29 43
30 void SetDecryptConfig(const DecryptConfig& decrypt_config); 44 void SetDecryptConfig(const DecryptConfig& decrypt_config);
31 45
32 int32 id() const { return id_; } 46 int32 id() const { return id_; }
33 base::SharedMemoryHandle handle() const { return handle_; } 47 base::SharedMemoryHandle handle() const { return handle_; }
48
49 // The number of bytes of the actual bitstream data. It is the size of the
50 // content instead of the whole shared memory.
34 size_t size() const { return size_; } 51 size_t size() const { return size_; }
35 52
53 // The offset to the start of actual bitstream data in the shared memory.
54 off_t offset() const { return offset_; }
55
36 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. 56 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|.
37 base::TimeDelta presentation_timestamp() const { 57 base::TimeDelta presentation_timestamp() const {
38 return presentation_timestamp_; 58 return presentation_timestamp_;
39 } 59 }
40 60
41 // The following methods come from DecryptConfig. 61 // The following methods come from DecryptConfig.
42 62
43 const std::string& key_id() const { return key_id_; } 63 const std::string& key_id() const { return key_id_; }
44 const std::string& iv() const { return iv_; } 64 const std::string& iv() const { return iv_; }
45 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } 65 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; }
46 66
47 private: 67 private:
48 int32 id_; 68 int32 id_;
49 base::SharedMemoryHandle handle_; 69 base::SharedMemoryHandle handle_;
50 size_t size_; 70 size_t size_;
71 off_t offset_;
51 72
52 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator 73 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator
53 // needs the timestamp because the underlying decoder may require it to 74 // needs the timestamp because the underlying decoder may require it to
54 // determine the output order. 75 // determine the output order.
55 base::TimeDelta presentation_timestamp_; 76 base::TimeDelta presentation_timestamp_;
56 77
57 // The following fields come from DecryptConfig. 78 // The following fields come from DecryptConfig.
58 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as 79 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as
59 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. 80 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed.
60 81
61 std::string key_id_; // key ID. 82 std::string key_id_; // key ID.
62 std::string iv_; // initialization vector 83 std::string iv_; // initialization vector
63 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes 84 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes
64 85
65 // Allow compiler-generated copy & assign constructors. 86 // Allow compiler-generated copy & assign constructors.
66 }; 87 };
67 88
68 } // namespace media 89 } // namespace media
69 90
70 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ 91 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698