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

Side by Side Diff: media/formats/webm/cluster_builder.h

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_FORMATS_WEBM_CLUSTER_BUILDER_H_ 5 #ifndef MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
6 #define MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_ 6 #define MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 class Cluster { 16 class Cluster {
16 public: 17 public:
17 Cluster(scoped_ptr<uint8_t[]> data, int size); 18 Cluster(std::unique_ptr<uint8_t[]> data, int size);
18 ~Cluster(); 19 ~Cluster();
19 20
20 const uint8_t* data() const { return data_.get(); } 21 const uint8_t* data() const { return data_.get(); }
21 int size() const { return size_; } 22 int size() const { return size_; }
22 23
23 private: 24 private:
24 scoped_ptr<uint8_t[]> data_; 25 std::unique_ptr<uint8_t[]> data_;
25 int size_; 26 int size_;
26 27
27 DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster); 28 DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster);
28 }; 29 };
29 30
30 class ClusterBuilder { 31 class ClusterBuilder {
31 public: 32 public:
32 ClusterBuilder(); 33 ClusterBuilder();
33 ~ClusterBuilder(); 34 ~ClusterBuilder();
34 35
35 void SetClusterTimecode(int64_t cluster_timecode); 36 void SetClusterTimecode(int64_t cluster_timecode);
36 void AddSimpleBlock(int track_num, 37 void AddSimpleBlock(int track_num,
37 int64_t timecode, 38 int64_t timecode,
38 int flags, 39 int flags,
39 const uint8_t* data, 40 const uint8_t* data,
40 int size); 41 int size);
41 void AddBlockGroup(int track_num, 42 void AddBlockGroup(int track_num,
42 int64_t timecode, 43 int64_t timecode,
43 int duration, 44 int duration,
44 int flags, 45 int flags,
45 const uint8_t* data, 46 const uint8_t* data,
46 int size); 47 int size);
47 void AddBlockGroupWithoutBlockDuration(int track_num, 48 void AddBlockGroupWithoutBlockDuration(int track_num,
48 int64_t timecode, 49 int64_t timecode,
49 int flags, 50 int flags,
50 const uint8_t* data, 51 const uint8_t* data,
51 int size); 52 int size);
52 53
53 scoped_ptr<Cluster> Finish(); 54 std::unique_ptr<Cluster> Finish();
54 scoped_ptr<Cluster> FinishWithUnknownSize(); 55 std::unique_ptr<Cluster> FinishWithUnknownSize();
55 56
56 private: 57 private:
57 void AddBlockGroupInternal(int track_num, 58 void AddBlockGroupInternal(int track_num,
58 int64_t timecode, 59 int64_t timecode,
59 bool include_block_duration, 60 bool include_block_duration,
60 int duration, 61 int duration,
61 int flags, 62 int flags,
62 const uint8_t* data, 63 const uint8_t* data,
63 int size); 64 int size);
64 void Reset(); 65 void Reset();
65 void ExtendBuffer(int bytes_needed); 66 void ExtendBuffer(int bytes_needed);
66 void UpdateUInt64(int offset, int64_t value); 67 void UpdateUInt64(int offset, int64_t value);
67 void WriteBlock(uint8_t* buf, 68 void WriteBlock(uint8_t* buf,
68 int track_num, 69 int track_num,
69 int64_t timecode, 70 int64_t timecode,
70 int flags, 71 int flags,
71 const uint8_t* data, 72 const uint8_t* data,
72 int size); 73 int size);
73 74
74 scoped_ptr<uint8_t[]> buffer_; 75 std::unique_ptr<uint8_t[]> buffer_;
75 int buffer_size_; 76 int buffer_size_;
76 int bytes_used_; 77 int bytes_used_;
77 int64_t cluster_timecode_; 78 int64_t cluster_timecode_;
78 79
79 DISALLOW_COPY_AND_ASSIGN(ClusterBuilder); 80 DISALLOW_COPY_AND_ASSIGN(ClusterBuilder);
80 }; 81 };
81 82
82 } // namespace media 83 } // namespace media
83 84
84 #endif // MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_ 85 #endif // MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698