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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_E
NCODER_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_E
NCODER_H_ |
6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_E
NCODER_H_ | 6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_E
NCODER_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
8 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
9 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_media
_encoder.h" | 11 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_media
_encoder.h" |
10 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
11 #include "media/video/video_encode_accelerator.h" | 13 #include "media/video/video_encode_accelerator.h" |
12 #include "third_party/wds/src/libwds/public/video_format.h" | 14 #include "third_party/wds/src/libwds/public/video_format.h" |
13 | 15 |
14 namespace extensions { | 16 namespace extensions { |
15 | 17 |
| 18 class WiFiDisplayElementaryStreamDescriptor; |
| 19 |
16 using WiFiDisplayEncodedFrame = WiFiDisplayEncodedUnit; | 20 using WiFiDisplayEncodedFrame = WiFiDisplayEncodedUnit; |
17 | 21 |
18 // This interface represents H.264 video encoder used by the | 22 // This interface represents H.264 video encoder used by the |
19 // Wi-Fi Display media pipeline. | 23 // Wi-Fi Display media pipeline. |
20 // Threading: the client code should belong to a single thread. | 24 // Threading: the client code should belong to a single thread. |
21 class WiFiDisplayVideoEncoder : public WiFiDisplayMediaEncoder { | 25 class WiFiDisplayVideoEncoder : public WiFiDisplayMediaEncoder { |
22 public: | 26 public: |
23 using VideoEncoderCallback = | 27 using VideoEncoderCallback = |
24 base::Callback<void(scoped_refptr<WiFiDisplayVideoEncoder>)>; | 28 base::Callback<void(scoped_refptr<WiFiDisplayVideoEncoder>)>; |
25 | 29 |
(...skipping 21 matching lines...) Expand all Loading... |
47 CreateEncodeMemoryCallback create_memory_callback; | 51 CreateEncodeMemoryCallback create_memory_callback; |
48 CreateVideoEncodeAcceleratorCallback vea_create_callback; | 52 CreateVideoEncodeAcceleratorCallback vea_create_callback; |
49 }; | 53 }; |
50 | 54 |
51 // A factory method that creates a new encoder instance from the given | 55 // A factory method that creates a new encoder instance from the given |
52 // |params|, the encoder instance is returned as an argument of | 56 // |params|, the encoder instance is returned as an argument of |
53 // |result_callback| ('nullptr' argument means encoder creation failure). | 57 // |result_callback| ('nullptr' argument means encoder creation failure). |
54 static void Create(const InitParameters& params, | 58 static void Create(const InitParameters& params, |
55 const VideoEncoderCallback& encoder_callback); | 59 const VideoEncoderCallback& encoder_callback); |
56 | 60 |
| 61 // WiFiDisplayMediaEncoder |
| 62 WiFiDisplayElementaryStreamInfo CreateElementaryStreamInfo() const final; |
| 63 |
57 // Encodes the given raw frame. The resulting encoded frame is passed | 64 // Encodes the given raw frame. The resulting encoded frame is passed |
58 // as an |encoded_callback|'s argument which is set via 'SetCallbacks' | 65 // as an |encoded_callback|'s argument which is set via 'SetCallbacks' |
59 // method. | 66 // method. |
60 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 67 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
61 base::TimeTicks reference_time); | 68 base::TimeTicks reference_time); |
62 | 69 |
63 // Requests the next encoded frame to be an instantaneous decoding refresh | 70 // Requests the next encoded frame to be an instantaneous decoding refresh |
64 // (IDR) picture. | 71 // (IDR) picture. |
65 void RequestIDRPicture(); | 72 void RequestIDRPicture(); |
66 | 73 |
67 protected: | 74 protected: |
68 // A factory method that creates a new encoder instance which uses Video | 75 // A factory method that creates a new encoder instance which uses Video |
69 // Encode Accelerator (VEA) for encoding. | 76 // Encode Accelerator (VEA) for encoding. |
70 static void CreateVEA(const InitParameters& params, | 77 static void CreateVEA(const InitParameters& params, |
71 const VideoEncoderCallback& encoder_callback); | 78 const VideoEncoderCallback& encoder_callback); |
72 | 79 |
73 explicit WiFiDisplayVideoEncoder( | 80 explicit WiFiDisplayVideoEncoder( |
74 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); | 81 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); |
75 ~WiFiDisplayVideoEncoder() override; | 82 ~WiFiDisplayVideoEncoder() override; |
76 | 83 |
77 virtual void InsertFrameOnMediaThread( | 84 virtual void InsertFrameOnMediaThread( |
78 scoped_refptr<media::VideoFrame> video_frame, | 85 scoped_refptr<media::VideoFrame> video_frame, |
79 base::TimeTicks reference_time, | 86 base::TimeTicks reference_time, |
80 bool send_idr) = 0; | 87 bool send_idr) = 0; |
81 | 88 |
| 89 std::vector<WiFiDisplayElementaryStreamDescriptor> descriptors_; |
82 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
83 bool send_idr_; | 91 bool send_idr_; |
84 }; | 92 }; |
85 | 93 |
86 } // namespace extensions | 94 } // namespace extensions |
87 | 95 |
88 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDE
O_ENCODER_H_ | 96 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDE
O_ENCODER_H_ |
OLD | NEW |