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

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

Issue 1814553002: Motown: Improvements to packet definition (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Added a comment. Created 4 years, 9 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/formatting.cc ('k') | services/media/framework/packet.cc » ('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 #ifndef SERVICES_MEDIA_FRAMEWORK_PACKET_H_ 5 #ifndef SERVICES_MEDIA_FRAMEWORK_PACKET_H_
6 #define SERVICES_MEDIA_FRAMEWORK_PACKET_H_ 6 #define SERVICES_MEDIA_FRAMEWORK_PACKET_H_
7 7
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 14 matching lines...) Expand all
25 typedef std::unique_ptr<Packet, PacketDeleter> PacketPtr; 25 typedef std::unique_ptr<Packet, PacketDeleter> PacketPtr;
26 26
27 // Media packet abstract base class. Subclasses may be defined as needed. 27 // Media packet abstract base class. Subclasses may be defined as needed.
28 // Packet::Create and Packet::CreateEndOfStream use an implementation with 28 // Packet::Create and Packet::CreateEndOfStream use an implementation with
29 // no special behavior. 29 // no special behavior.
30 // TODO(dalesat): Revisit this definition: 30 // TODO(dalesat): Revisit this definition:
31 // 1) We probably need an extensible way to add metadata to packets. 31 // 1) We probably need an extensible way to add metadata to packets.
32 // 2) The relationship to the allocator could be clearer. 32 // 2) The relationship to the allocator could be clearer.
33 class Packet { 33 class Packet {
34 public: 34 public:
35 static const int64_t kUnknownPresentationTime = 35 static const int64_t kUnknownPts = std::numeric_limits<int64_t>::min();
36 std::numeric_limits<int64_t>::min();
37 36
38 // Creates a packet. If size is 0, payload must be nullptr and vice-versa. 37 // Creates a packet. If size is 0, payload must be nullptr and vice-versa.
39 // If payload is not nullptr, an allocator must be provided. 38 // If payload is not nullptr, an allocator must be provided.
40 static PacketPtr Create( 39 static PacketPtr Create(
41 int64_t presentation_time, 40 int64_t pts,
42 uint64_t duration,
43 bool end_of_stream, 41 bool end_of_stream,
44 size_t size, 42 size_t size,
45 void* payload, 43 void* payload,
46 PayloadAllocator* allocator); 44 PayloadAllocator* allocator);
47 45
48 // Creates a packet. If size is 0, payload must be nullptr and vice-versa. 46 // Creates a packet. If size is 0, payload must be nullptr and vice-versa.
49 // No allocator is provided, and the payload will not be released when the 47 // No allocator is provided, and the payload will not be released when the
50 // packet is released. 48 // packet is released.
51 static PacketPtr CreateNoAllocator( 49 static PacketPtr CreateNoAllocator(
52 int64_t presentation_time, 50 int64_t pts,
53 uint64_t duration,
54 bool end_of_stream, 51 bool end_of_stream,
55 size_t size, 52 size_t size,
56 void* payload); 53 void* payload);
57 54
58 // Creates an end-of-stream packet with no payload. 55 // Creates an end-of-stream packet with no payload.
59 static PacketPtr CreateEndOfStream(int64_t presentation_time); 56 static PacketPtr CreateEndOfStream(int64_t pts);
60 57
61 virtual int64_t presentation_time() const = 0; 58 int64_t pts() const { return pts_; }
62 59
63 virtual uint64_t duration() const = 0; 60 bool end_of_stream() const { return end_of_stream_; }
64 61
65 virtual bool end_of_stream() const = 0; 62 size_t size() const { return size_; }
66 63
67 virtual size_t size() const = 0; 64 void* payload() const { return payload_; }
68
69 virtual void* payload() const = 0;
70 65
71 protected: 66 protected:
67 Packet(
68 int64_t pts,
69 bool end_of_stream,
70 size_t size,
71 void* payload);
72
72 virtual ~Packet() {} 73 virtual ~Packet() {}
73 74
74 virtual void Release() = 0; 75 virtual void Release() = 0;
75 76
77 private:
78 int64_t pts_;
79 bool end_of_stream_;
80 size_t size_;
81 void* payload_;
82
76 friend PacketDeleter; 83 friend PacketDeleter;
77 }; 84 };
78 85
79 inline void PacketDeleter::operator()(Packet* ptr) const { 86 inline void PacketDeleter::operator()(Packet* ptr) const {
80 DCHECK(ptr); 87 DCHECK(ptr);
81 ptr->Release(); 88 ptr->Release();
82 } 89 }
83 90
84 } // namespace media 91 } // namespace media
85 } // namespace mojo 92 } // namespace mojo
86 93
87 #endif // SERVICES_MEDIA_FRAMEWORK_PACKET_H_ 94 #endif // SERVICES_MEDIA_FRAMEWORK_PACKET_H_
OLDNEW
« no previous file with comments | « services/media/framework/formatting.cc ('k') | services/media/framework/packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698