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

Side by Side Diff: services/media/framework/packet.cc

Issue 1678433002: Motown: Remove LPCM optimizations, fix prepare, add flush, add ActiveMultistreamSink model/stage (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Sync 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
« no previous file with comments | « services/media/framework/packet.h ('k') | services/media/framework/parts/decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "services/media/framework/allocator.h"
7 #include "services/media/framework/packet.h" 6 #include "services/media/framework/packet.h"
7 #include "services/media/framework/payload_allocator.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace media { 10 namespace media {
11 11
12 class PacketImpl : public Packet { 12 class PacketImpl : public Packet {
13 public: 13 public:
14 PacketImpl( 14 PacketImpl(
15 int64_t presentation_time, 15 int64_t presentation_time,
16 uint64_t duration, 16 uint64_t duration,
17 bool end_of_stream, 17 bool end_of_stream,
18 uint64_t size, 18 size_t size,
19 void* payload, 19 void* payload,
20 Allocator* allocator) : 20 PayloadAllocator* allocator) :
21 presentation_time_(presentation_time), 21 presentation_time_(presentation_time),
22 duration_(duration), 22 duration_(duration),
23 end_of_stream_(end_of_stream), 23 end_of_stream_(end_of_stream),
24 size_(size), 24 size_(size),
25 payload_(payload), 25 payload_(payload),
26 allocator_(allocator) { 26 allocator_(allocator) {
27 DCHECK((size == 0) == (payload == nullptr)); 27 DCHECK((size == 0) == (payload == nullptr));
28 } 28 }
29 29
30 ~PacketImpl() override {}; 30 ~PacketImpl() override {};
31 31
32 int64_t presentation_time() const override { return presentation_time_; } 32 int64_t presentation_time() const override { return presentation_time_; }
33 33
34 uint64_t duration() const override { return duration_; } 34 uint64_t duration() const override { return duration_; }
35 35
36 bool end_of_stream() const override { return end_of_stream_; } 36 bool end_of_stream() const override { return end_of_stream_; }
37 37
38 uint64_t size() const override { return size_; } 38 size_t size() const override { return size_; }
39 39
40 void* payload() const override { return payload_; } 40 void* payload() const override { return payload_; }
41 41
42 protected: 42 protected:
43 void Release() override { 43 void Release() override {
44 if (payload_ != nullptr && allocator_ != nullptr) { 44 if (payload_ != nullptr && allocator_ != nullptr) {
45 DCHECK(allocator_); 45 DCHECK(allocator_);
46 allocator_->ReleasePayloadBuffer(size_, payload_); 46 allocator_->ReleasePayloadBuffer(size_, payload_);
47 } 47 }
48 delete this; 48 delete this;
49 } 49 }
50 50
51 private: 51 private:
52 int64_t presentation_time_; 52 int64_t presentation_time_;
53 uint64_t duration_; 53 uint64_t duration_;
54 bool end_of_stream_; 54 bool end_of_stream_;
55 uint64_t size_; 55 size_t size_;
56 void* payload_; 56 void* payload_;
57 Allocator* allocator_; 57 PayloadAllocator* allocator_;
58 }; 58 };
59 59
60 // static 60 // static
61 PacketPtr Packet::Create( 61 PacketPtr Packet::Create(
62 int64_t presentation_time, 62 int64_t presentation_time,
63 uint64_t duration, 63 uint64_t duration,
64 bool end_of_stream, 64 bool end_of_stream,
65 uint64_t size, 65 size_t size,
66 void* payload, 66 void* payload,
67 Allocator* allocator) { 67 PayloadAllocator* allocator) {
68 DCHECK(payload == nullptr || allocator != nullptr); 68 DCHECK(payload == nullptr || allocator != nullptr);
69 return PacketPtr(new PacketImpl( 69 return PacketPtr(new PacketImpl(
70 presentation_time, 70 presentation_time,
71 duration, 71 duration,
72 end_of_stream, 72 end_of_stream,
73 size, 73 size,
74 payload, 74 payload,
75 allocator)); 75 allocator));
76 } 76 }
77 77
78 // static 78 // static
79 PacketPtr Packet::CreateNoAllocator( 79 PacketPtr Packet::CreateNoAllocator(
80 int64_t presentation_time, 80 int64_t presentation_time,
81 uint64_t duration, 81 uint64_t duration,
82 bool end_of_stream, 82 bool end_of_stream,
83 uint64_t size, 83 size_t size,
84 void* payload) { 84 void* payload) {
85 return PacketPtr(new PacketImpl( 85 return PacketPtr(new PacketImpl(
86 presentation_time, 86 presentation_time,
87 duration, 87 duration,
88 end_of_stream, 88 end_of_stream,
89 size, 89 size,
90 payload, 90 payload,
91 nullptr)); 91 nullptr));
92 } 92 }
93 93
94 // static 94 // static
95 PacketPtr Packet::CreateEndOfStream(int64_t presentation_time) { 95 PacketPtr Packet::CreateEndOfStream(int64_t presentation_time) {
96 return PacketPtr(new PacketImpl( 96 return PacketPtr(new PacketImpl(
97 presentation_time, 97 presentation_time,
98 0, // duration 98 0, // duration
99 true, // end_of_stream 99 true, // end_of_stream
100 0, // size 100 0, // size
101 nullptr, // payload 101 nullptr, // payload
102 nullptr)); // allocator 102 nullptr)); // allocator
103 } 103 }
104 104
105 } // namespace media 105 } // namespace media
106 } // namespace mojo 106 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/framework/packet.h ('k') | services/media/framework/parts/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698