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

Side by Side Diff: mojo/services/media/common/cpp/video_renderer.h

Issue 2068043005: Motown: Video renderer library code (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. Created 4 years, 6 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 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_
6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_
7
8 #include <memory>
9 #include <queue>
10
11 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h"
13 #include "mojo/services/media/common/cpp/timeline_function.h"
14 #include "mojo/services/media/common/cpp/video_converter.h"
15 #include "mojo/services/media/common/interfaces/media_transport.mojom.h"
16 #include "mojo/services/media/core/interfaces/media_renderer.mojom.h"
17
18 namespace mojo {
19 namespace media {
20
21 // Implements MediaRenderer for an app that wants to show video.
22 class VideoRenderer : public MediaRenderer,
23 public MediaConsumer,
24 public MediaTimelineControlSite,
25 public TimelineConsumer {
26 public:
27 VideoRenderer();
28
29 ~VideoRenderer() override;
30
31 void Bind(InterfaceRequest<MediaRenderer> renderer_request);
32
33 // Gets an RGBA video frame corresponding to the specified reference time.
34 // |width| and |height| refer to |rgba_buffer|.
35 void GetRgbaFrame(uint8_t* rgba_buffer,
36 size_t width,
37 size_t height,
38 int64_t reference_time);
39
40 private:
41 struct PacketAndCallback {
42 PacketAndCallback(MediaPacketPtr packet,
43 const SendPacketCallback& callback);
44
45 ~PacketAndCallback();
46
47 MediaPacketPtr packet_;
48 SendPacketCallback callback_;
49 };
50
51 // MediaRenderer implementation.
52 void GetSupportedMediaTypes(
53 const GetSupportedMediaTypesCallback& callback) override;
54
55 void SetMediaType(MediaTypePtr media_type) override;
56
57 void GetConsumer(InterfaceRequest<MediaConsumer> consumer_request) override;
58
59 void GetTimelineControlSite(
60 InterfaceRequest<MediaTimelineControlSite> control_site_request) override;
61
62 // MediaConsumer implementation.
63 void SetBuffer(ScopedSharedBufferHandle buffer,
64 const SetBufferCallback& callback) override;
65
66 void SendPacket(MediaPacketPtr packet,
67 const SendPacketCallback& callback) override;
68
69 void Prime(const PrimeCallback& callback) override;
70
71 void Flush(const FlushCallback& callback) override;
72
73 // MediaTimelineControlSite implementation.
74 void GetStatus(uint64_t version_last_seen,
75 const GetStatusCallback& callback) override;
76
77 void GetTimelineConsumer(
78 InterfaceRequest<TimelineConsumer> timeline_consumer_request) override;
79
80 // TimelineConsumer implementation.
81 void SetTimelineTransform(
82 int64_t subject_time,
83 uint32_t reference_delta,
84 uint32_t subject_delta,
85 int64_t effective_reference_time,
86 int64_t effective_subject_time,
87 const SetTimelineTransformCallback& callback) override;
88
89 // Clears the pending timeline function and calls its associated callback
90 // with the indicated completed status.
91 void ClearPendingTimelineFunction(bool completed);
92
93 // Apply a pending timeline change if there is one an it's due.
94 void MaybeApplyPendingTimelineChange(int64_t reference_time);
95
96 // Publishes end-of-stream as needed.
97 void MaybePublishEndOfStream();
98
99 // Sends status updates to waiting callers of GetStatus.
100 void SendStatusUpdates();
101
102 // Calls the callback with the current status.
103 void CompleteGetStatus(const GetStatusCallback& callback);
104
105 Binding<MediaRenderer> renderer_binding_;
106 Binding<MediaConsumer> consumer_binding_;
107 Binding<MediaTimelineControlSite> control_site_binding_;
108 Binding<TimelineConsumer> timeline_consumer_binding_;
109 MappedSharedBuffer shared_buffer_;
110 std::queue<PacketAndCallback> packet_queue_;
111 TimelineFunction current_timeline_function_;
112 TimelineFunction pending_timeline_function_;
113 SetTimelineTransformCallback set_timeline_transform_callback_;
114 int64_t end_of_stream_pts_ = kUnspecifiedTime;
115 bool end_of_stream_published_ = false;
116 uint64_t status_version_ = 1u;
117 std::vector<GetStatusCallback> pending_status_callbacks_;
118 VideoConverter converter_;
119 };
120
121 } // namespace media
122 } // namespace moj
123
124 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_
OLDNEW
« no previous file with comments | « mojo/services/media/common/cpp/video_packet_layout.cc ('k') | mojo/services/media/common/cpp/video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698