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

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: rebase over crrev.com/1645873002 Created 4 years, 10 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 "ipc/ipc_param_traits.h" 14 #include "ipc/ipc_param_traits.h"
15 #include "media/base/decrypt_config.h" 15 #include "media/base/decrypt_config.h"
16 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
17 #include "media/base/timestamp_constants.h" 17 #include "media/base/timestamp_constants.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 // 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
22 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev. 22 // data. This is the media-namespace equivalent of PP_VideoBitstreamBuffer_Dev.
23 class MEDIA_EXPORT BitstreamBuffer { 23 class MEDIA_EXPORT BitstreamBuffer {
24 public: 24 public:
25 BitstreamBuffer(); 25 BitstreamBuffer();
26 26
27 BitstreamBuffer(int32_t id, base::SharedMemoryHandle handle, size_t size); 27 // Constructs a new BitstreamBuffer. The content of the bitstream is located
28 28 // at |offset| bytes away from the start of the shared memory and the payload
29 // is |size| bytes. When not provided, the default value for |offset| is 0.
30 // |presentation_timestamp| is when the decoded frame should be displayed.
31 // When not provided, |presentation_timestamp| will be
32 // |media::kNoTimestamp()|.
29 BitstreamBuffer(int32_t id, 33 BitstreamBuffer(int32_t id,
30 base::SharedMemoryHandle handle, 34 base::SharedMemoryHandle handle,
31 size_t size, 35 size_t size,
32 base::TimeDelta presentation_timestamp); 36 off_t offset = 0,
37 base::TimeDelta presentation_timestamp = kNoTimestamp());
33 38
34 ~BitstreamBuffer(); 39 ~BitstreamBuffer();
35 40
36 void SetDecryptConfig(const DecryptConfig& decrypt_config); 41 void SetDecryptConfig(const DecryptConfig& decrypt_config);
37 42
38 int32_t id() const { return id_; } 43 int32_t id() const { return id_; }
39 base::SharedMemoryHandle handle() const { return handle_; } 44 base::SharedMemoryHandle handle() const { return handle_; }
45
46 // The number of bytes of the actual bitstream data. It is the size of the
47 // content instead of the whole shared memory.
40 size_t size() const { return size_; } 48 size_t size() const { return size_; }
41 49
42 void set_handle(const base::SharedMemoryHandle& handle) { handle_ = handle; } 50 // The offset to the start of actual bitstream data in the shared memory.
51 off_t offset() const { return offset_; }
43 52
44 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|. 53 // The timestamp is only valid if it's not equal to |media::kNoTimestamp()|.
45 base::TimeDelta presentation_timestamp() const { 54 base::TimeDelta presentation_timestamp() const {
46 return presentation_timestamp_; 55 return presentation_timestamp_;
47 } 56 }
48 57
58 void set_handle(const base::SharedMemoryHandle& handle) { handle_ = handle; }
59
49 // The following methods come from DecryptConfig. 60 // The following methods come from DecryptConfig.
50 61
51 const std::string& key_id() const { return key_id_; } 62 const std::string& key_id() const { return key_id_; }
52 const std::string& iv() const { return iv_; } 63 const std::string& iv() const { return iv_; }
53 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } 64 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; }
54 65
55 private: 66 private:
56 int32_t id_; 67 int32_t id_;
57 base::SharedMemoryHandle handle_; 68 base::SharedMemoryHandle handle_;
58 size_t size_; 69 size_t size_;
70 off_t offset_;
59 71
60 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator 72 // This is only set when necessary. For example, AndroidVideoDecodeAccelerator
61 // needs the timestamp because the underlying decoder may require it to 73 // needs the timestamp because the underlying decoder may require it to
62 // determine the output order. 74 // determine the output order.
63 base::TimeDelta presentation_timestamp_; 75 base::TimeDelta presentation_timestamp_;
64 76
65 // The following fields come from DecryptConfig. 77 // The following fields come from DecryptConfig.
66 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as 78 // TODO(timav): Try to DISALLOW_COPY_AND_ASSIGN and include these params as
67 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed. 79 // scoped_ptr<DecryptConfig> or explain why copy & assign is needed.
68 80
69 std::string key_id_; // key ID. 81 std::string key_id_; // key ID.
70 std::string iv_; // initialization vector 82 std::string iv_; // initialization vector
71 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes 83 std::vector<SubsampleEntry> subsamples_; // clear/cypher sizes
72 84
73 friend struct IPC::ParamTraits<media::BitstreamBuffer>; 85 friend struct IPC::ParamTraits<media::BitstreamBuffer>;
74 86
75 // Allow compiler-generated copy & assign constructors. 87 // Allow compiler-generated copy & assign constructors.
76 }; 88 };
77 89
78 } // namespace media 90 } // namespace media
79 91
80 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_ 92 #endif // MEDIA_BASE_BITSTREAM_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698