| OLD | NEW |
| 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 MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ | 5 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ |
| 6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ | 6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/services/geometry/interfaces/geometry.mojom.h" | 12 #include "mojo/services/geometry/interfaces/geometry.mojom.h" |
| 13 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h" | 13 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h" |
| 14 #include "mojo/services/media/common/cpp/timeline_function.h" | 14 #include "mojo/services/media/common/cpp/timeline_function.h" |
| 15 #include "mojo/services/media/common/cpp/video_converter.h" | 15 #include "mojo/services/media/common/cpp/video_converter.h" |
| 16 #include "mojo/services/media/common/interfaces/media_transport.mojom.h" | 16 #include "mojo/services/media/common/interfaces/media_transport.mojom.h" |
| 17 #include "mojo/services/media/core/interfaces/media_renderer.mojom.h" | 17 #include "mojo/services/media/core/interfaces/media_renderer.mojom.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace media { | 20 namespace media { |
| 21 | 21 |
| 22 // Implements MediaRenderer for an app that wants to show video. | 22 // Implements MediaRenderer for an app that wants to show video. |
| 23 class VideoRenderer : public MediaRenderer, | 23 class VideoRenderer : public MediaRenderer, |
| 24 public MediaConsumer, | 24 public MediaPacketConsumer, |
| 25 public MediaTimelineControlPoint, | 25 public MediaTimelineControlPoint, |
| 26 public TimelineConsumer { | 26 public TimelineConsumer { |
| 27 public: | 27 public: |
| 28 VideoRenderer(); | 28 VideoRenderer(); |
| 29 | 29 |
| 30 ~VideoRenderer() override; | 30 ~VideoRenderer() override; |
| 31 | 31 |
| 32 void Bind(InterfaceRequest<MediaRenderer> renderer_request); | 32 void Bind(InterfaceRequest<MediaRenderer> renderer_request); |
| 33 | 33 |
| 34 // Get the size of the video to be rendered. | 34 // Get the size of the video to be rendered. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 MediaPacketPtr packet_; | 49 MediaPacketPtr packet_; |
| 50 SendPacketCallback callback_; | 50 SendPacketCallback callback_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // MediaRenderer implementation. | 53 // MediaRenderer implementation. |
| 54 void GetSupportedMediaTypes( | 54 void GetSupportedMediaTypes( |
| 55 const GetSupportedMediaTypesCallback& callback) override; | 55 const GetSupportedMediaTypesCallback& callback) override; |
| 56 | 56 |
| 57 void SetMediaType(MediaTypePtr media_type) override; | 57 void SetMediaType(MediaTypePtr media_type) override; |
| 58 | 58 |
| 59 void GetConsumer(InterfaceRequest<MediaConsumer> consumer_request) override; | 59 void GetPacketConsumer( |
| 60 InterfaceRequest<MediaPacketConsumer> consumer_request) override; |
| 60 | 61 |
| 61 void GetTimelineControlPoint(InterfaceRequest<MediaTimelineControlPoint> | 62 void GetTimelineControlPoint(InterfaceRequest<MediaTimelineControlPoint> |
| 62 control_point_request) override; | 63 control_point_request) override; |
| 63 | 64 |
| 64 // MediaConsumer implementation. | 65 // MediaPacketConsumer implementation. |
| 65 void SetBuffer(ScopedSharedBufferHandle buffer, | 66 void SetBuffer(ScopedSharedBufferHandle buffer, |
| 66 const SetBufferCallback& callback) override; | 67 const SetBufferCallback& callback) override; |
| 67 | 68 |
| 68 void SendPacket(MediaPacketPtr packet, | 69 void SendPacket(MediaPacketPtr packet, |
| 69 const SendPacketCallback& callback) override; | 70 const SendPacketCallback& callback) override; |
| 70 | 71 |
| 71 void Prime(const PrimeCallback& callback) override; | 72 void Prime(const PrimeCallback& callback) override; |
| 72 | 73 |
| 73 void Flush(const FlushCallback& callback) override; | 74 void Flush(const FlushCallback& callback) override; |
| 74 | 75 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 // Publishes end-of-stream as needed. | 95 // Publishes end-of-stream as needed. |
| 95 void MaybePublishEndOfStream(); | 96 void MaybePublishEndOfStream(); |
| 96 | 97 |
| 97 // Sends status updates to waiting callers of GetStatus. | 98 // Sends status updates to waiting callers of GetStatus. |
| 98 void SendStatusUpdates(); | 99 void SendStatusUpdates(); |
| 99 | 100 |
| 100 // Calls the callback with the current status. | 101 // Calls the callback with the current status. |
| 101 void CompleteGetStatus(const GetStatusCallback& callback); | 102 void CompleteGetStatus(const GetStatusCallback& callback); |
| 102 | 103 |
| 103 Binding<MediaRenderer> renderer_binding_; | 104 Binding<MediaRenderer> renderer_binding_; |
| 104 Binding<MediaConsumer> consumer_binding_; | 105 Binding<MediaPacketConsumer> consumer_binding_; |
| 105 Binding<MediaTimelineControlPoint> control_point_binding_; | 106 Binding<MediaTimelineControlPoint> control_point_binding_; |
| 106 Binding<TimelineConsumer> timeline_consumer_binding_; | 107 Binding<TimelineConsumer> timeline_consumer_binding_; |
| 107 MappedSharedBuffer shared_buffer_; | 108 MappedSharedBuffer shared_buffer_; |
| 108 std::queue<PacketAndCallback> packet_queue_; | 109 std::queue<PacketAndCallback> packet_queue_; |
| 109 TimelineFunction current_timeline_function_; | 110 TimelineFunction current_timeline_function_; |
| 110 TimelineFunction pending_timeline_function_; | 111 TimelineFunction pending_timeline_function_; |
| 111 SetTimelineTransformCallback set_timeline_transform_callback_; | 112 SetTimelineTransformCallback set_timeline_transform_callback_; |
| 112 int64_t end_of_stream_pts_ = kUnspecifiedTime; | 113 int64_t end_of_stream_pts_ = kUnspecifiedTime; |
| 113 bool end_of_stream_published_ = false; | 114 bool end_of_stream_published_ = false; |
| 114 uint64_t status_version_ = 1u; | 115 uint64_t status_version_ = 1u; |
| 115 std::vector<GetStatusCallback> pending_status_callbacks_; | 116 std::vector<GetStatusCallback> pending_status_callbacks_; |
| 116 VideoConverter converter_; | 117 VideoConverter converter_; |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 } // namespace media | 120 } // namespace media |
| 120 } // namespace moj | 121 } // namespace moj |
| 121 | 122 |
| 122 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ | 123 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_VIDEO_RENDERER_H_ |
| OLD | NEW |