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

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

Issue 1577953002: Motown in-proc streaming framework used to implement media services. (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "services/media/framework/allocator.h"
7 #include "services/media/framework/packet.h"
8
9 namespace mojo {
10 namespace media {
11
12 class PacketImpl : public Packet {
13 public:
14 PacketImpl(
15 int64_t presentation_time,
16 uint64_t duration,
17 bool end_of_stream,
18 uint64_t size,
19 void* payload,
20 Allocator* allocator) :
21 presentation_time_(presentation_time),
22 duration_(duration),
23 end_of_stream_(end_of_stream),
24 size_(size),
25 payload_(payload),
26 allocator_(allocator) {
27 DCHECK((size == 0) == (payload == nullptr));
28 }
29
30 ~PacketImpl() override {};
31
32 int64_t presentation_time() const override { return presentation_time_; }
33
34 uint64_t duration() const override { return duration_; }
35
36 bool end_of_stream() const override { return end_of_stream_; }
37
38 uint64_t size() const override { return size_; }
39
40 void* payload() const override { return payload_; }
41
42 protected:
43 void Release() override {
44 if (payload_ != nullptr && allocator_ != nullptr) {
45 DCHECK(allocator_);
46 allocator_->ReleasePayloadBuffer(size_, payload_);
47 }
48 delete this;
49 }
50
51 private:
52 int64_t presentation_time_;
53 uint64_t duration_;
54 bool end_of_stream_;
55 uint64_t size_;
56 void* payload_;
57 Allocator* allocator_;
58 };
59
60 // static
61 PacketPtr Packet::Create(
62 int64_t presentation_time,
63 uint64_t duration,
64 bool end_of_stream,
65 uint64_t size,
66 void* payload,
67 Allocator* allocator) {
68 DCHECK(payload == nullptr || allocator != nullptr);
69 return PacketPtr(new PacketImpl(
70 presentation_time,
71 duration,
72 end_of_stream,
73 size,
74 payload,
75 allocator));
76 }
77
78 // static
79 PacketPtr Packet::CreateNoAllocator(
80 int64_t presentation_time,
81 uint64_t duration,
82 bool end_of_stream,
83 uint64_t size,
84 void* payload) {
85 return PacketPtr(new PacketImpl(
86 presentation_time,
87 duration,
88 end_of_stream,
89 size,
90 payload,
91 nullptr));
92 }
93
94 // static
95 PacketPtr Packet::CreateEndOfStream(int64_t presentation_time) {
96 return PacketPtr(new PacketImpl(
97 presentation_time,
98 0, // duration
99 true, // end_of_stream
100 0, // size
101 nullptr, // payload
102 nullptr)); // allocator
103 }
104
105 } // namespace media
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