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

Unified Diff: services/media/framework/packet.h

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, 11 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 side-by-side diff with in-line comments
Download patch
Index: services/media/framework/packet.h
diff --git a/services/media/framework/packet.h b/services/media/framework/packet.h
new file mode 100644
index 0000000000000000000000000000000000000000..e3843b8f50dd667a895f5caf26cfa21592910075
--- /dev/null
+++ b/services/media/framework/packet.h
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_MEDIA_FRAMEWORK_PACKET_H_
+#define SERVICES_MEDIA_FRAMEWORK_PACKET_H_
+
+#include <memory>
+
+#include "base/logging.h"
+#include "services/media/framework/allocator.h"
+#include "services/media/framework/ptr.h"
+
+namespace mojo {
+namespace media {
+
+class Packet;
+
+// Used for PacketPtr.
+struct PacketDeleter {
+ void operator()(Packet* ptr) const;
+};
+
+// Unique pointer for packets.
+typedef UniquePtr<Packet, PacketDeleter> PacketPtr;
+
+// Media packet abstract base class. Subclasses may be defined as needed.
+// Packet::Create and Packet::CreateEndOfStream use an implementation with
+// no special behavior.
+class Packet {
+ public:
+ // Creates a packet. If size is 0, payload must be nullptr and vice-versa.
+ // If payload is not nullptr, an allocator must be provided.
+ static PacketPtr Create(
+ int64_t presentation_time,
+ uint64_t duration,
+ bool end_of_stream,
johngro 2016/01/26 01:32:39 <design_point note="No code change requested> PTS,
dalesat 2016/01/26 21:17:51 Ack comments about more metadata. Are you concern
johngro 2016/01/27 22:35:22 mildly; its one of those things which feel like a
dalesat 2016/01/28 18:49:15 Looking at my ffmpeg code, it appears that demuxes
johngro 2016/02/01 22:38:16 so I went ahead and checked in the current ffmpeg
dalesat 2016/02/01 23:01:28 Acknowledged.
+ uint64_t size,
+ void* payload,
+ Allocator* allocator);
johngro 2016/01/26 01:32:39 Looking at the implementation (next file), it seem
dalesat 2016/01/26 21:17:51 That's a worthy design idea. Can we save it for an
johngro 2016/01/27 22:35:22 sure, if you are serious about implementing it, yo
dalesat 2016/01/28 18:49:15 Acknowledged.
+
+ // Creates an end-of-stream packet with no payload.
+ static PacketPtr CreateEndOfStream(int64_t presentation_time);
+
+ virtual int64_t presentation_time() const = 0;
+
+ virtual uint64_t duration() const = 0;
+
+ virtual bool end_of_stream() const = 0;
+
+ virtual uint64_t size() const = 0;
+
+ virtual void* payload() const = 0;
+
+ protected:
+ virtual ~Packet() {}
+
+ virtual void release() = 0;
+
+ friend PacketDeleter;
+};
+
+inline void PacketDeleter::operator()(Packet* ptr) const {
+ DCHECK(ptr);
+ ptr->release();
+}
+
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_FRAMEWORK_PACKET_H_

Powered by Google App Engine
This is Rietveld 408576698