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

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: fix compiling errors on android 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 <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 // Constructs a new BitstreamBuffer. The content of the bitstream is located
25 25 // at |offset| bytes away from the start of the shared memory and the payload
26 // is |size| bytes. When not provided, the default value for |offset| is 0.
27 // |presentation_timestamp| is when the decoded frame should be displayed.
28 // When not provided, |presentation_timestamp| will be
29 // |media::kNoTimestamp()|.
26 BitstreamBuffer(int32_t id, 30 BitstreamBuffer(int32_t id,
27 base::SharedMemoryHandle handle, 31 base::SharedMemoryHandle handle,
28 size_t size, 32 size_t size,
29 base::TimeDelta presentation_timestamp); 33 off_t offset = 0,
34 base::TimeDelta presentation_timestamp = kNoTimestamp());
30 35
31 ~BitstreamBuffer(); 36 ~BitstreamBuffer();
32 37
33 void SetDecryptConfig(const DecryptConfig& decrypt_config); 38 void SetDecryptConfig(const DecryptConfig& decrypt_config);
34 39
35 int32_t id() const { return id_; } 40 int32_t id() const { return id_; }
36 base::SharedMemoryHandle handle() const { return handle_; } 41 base::SharedMemoryHandle handle() const { return handle_; }
42
43 // The number of bytes of the actual bitstream data. It is the size of the
44 // content instead of the whole shared memory.
37 size_t size() const { return size_; } 45 size_t size() const { return size_; }
38 46
47 // The offset to the start of actual bitstream data in the shared memory.
48 off_t offset() const { return offset_; }
dcheng 2016/01/22 18:27:39 Any particular to reason to use off_t? I know mmap
Pawel Osciak 2016/01/25 08:20:02 MapAt() will fail us if the offset is invalid, e.g
49
39 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. 50 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|.
40 base::TimeDelta presentation_timestamp() const { 51 base::TimeDelta presentation_timestamp() const {
41 return presentation_timestamp_; 52 return presentation_timestamp_;
42 } 53 }
43 54
44 // The following methods come from DecryptConfig. 55 // The following methods come from DecryptConfig.
45 56
46 const std::string& key_id() const { return key_id_; } 57 const std::string& key_id() const { return key_id_; }
47 const std::string& iv() const { return iv_; } 58 const std::string& iv() const { return iv_; }
48 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } 59 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; }
49 60
50 private: 61 private:
51 int32_t id_; 62 int32_t id_;
52 base::SharedMemoryHandle handle_; 63 base::SharedMemoryHandle handle_;
53 size_t size_; 64 size_t size_;
65 off_t offset_;
54 66
55 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator 67 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator
56 // needs the timestamp because the underlying decoder may require it to 68 // needs the timestamp because the underlying decoder may require it to
57 // determine the output order. 69 // determine the output order.
58 base::TimeDelta presentation_timestamp_; 70 base::TimeDelta presentation_timestamp_;
59 71
60 // The following fields come from DecryptConfig. 72 // The following fields come from DecryptConfig.
61 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as 73 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as
62 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. 74 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed.
63 75
64 std::string key_id_; // key ID. 76 std::string key_id_; // key ID.
65 std::string iv_; // initialization vector 77 std::string iv_; // initialization vector
66 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes 78 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes
67 79
68 // Allow compiler-generated copy & assign constructors. 80 // Allow compiler-generated copy & assign constructors.
69 }; 81 };
70 82
71 } // namespace media 83 } // namespace media
72 84
73 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ 85 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698