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

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: Changed lpcm input/output to use packets for supplying frames. Some name changes. Synced to master. 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
(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 DCHECK(payload == nullptr || allocator != nullptr);
29 }
30
31 ~PacketImpl() override {};
32
33 int64_t presentation_time() const override { return presentation_time_; }
34
35 uint64_t duration() const override { return duration_; }
36
37 bool end_of_stream() const override { return end_of_stream_; }
38
39 uint64_t size() const override { return size_; }
40
41 void* payload() const override { return payload_; }
42
43 protected:
44 void release() override {
45 if (payload_ != nullptr) {
46 DCHECK(allocator_);
47 allocator_->ReleasePayloadBuffer(size_, payload_);
48 }
49 delete this;
50 }
51
52 private:
53 int64_t presentation_time_;
54 uint64_t duration_;
55 bool end_of_stream_;
56 uint64_t size_;
57 void* payload_;
58 Allocator* allocator_;
59 };
60
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 return PacketPtr(new PacketImpl(
69 presentation_time,
70 duration,
71 end_of_stream,
72 size,
73 payload,
74 allocator));
75 }
76
77 PacketPtr Packet::CreateEndOfStream(int64_t presentation_time) {
78 return PacketPtr(new PacketImpl(
79 presentation_time,
80 0, // duration
81 true, // end_of_stream
82 0, // size
83 nullptr, // payload
84 nullptr)); // allocator
85 }
86
87 } // namespace media
88 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698