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

Side by Side Diff: content/renderer/media_recorder/h264_encoder.h

Issue 2793303003: Refactor VideoTrackRecorder into smaller classes (Closed)
Patch Set: Rebase Created 3 years, 8 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 | « content/renderer/BUILD.gn ('k') | content/renderer/media_recorder/h264_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 CONTENT_RENDERER_MEDIA_RECORDER_H264_ENCODER_H_
6 #define CONTENT_RENDERER_MEDIA_RECORDER_H264_ENCODER_H_
7
8 #include "content/public/common/features.h"
9
10 #if !BUILDFLAG(RTC_USE_H264)
11 #error RTC_USE_H264 should be defined.
12 #endif // #if BUILDFLAG(RTC_USE_H264)
13
14 #include "base/time/time.h"
15 #include "content/renderer/media_recorder/video_track_recorder.h"
16 #include "third_party/openh264/src/codec/api/svc/codec_api.h"
17
18 namespace content {
19
20 // Class encapsulating all openh264 interactions for H264 encoding.
21 class H264Encoder final : public VideoTrackRecorder::Encoder {
22 public:
23 struct ISVCEncoderDeleter {
24 void operator()(ISVCEncoder* codec);
25 };
26 typedef std::unique_ptr<ISVCEncoder, ISVCEncoderDeleter> ScopedISVCEncoderPtr;
27
28 static void ShutdownEncoder(std::unique_ptr<base::Thread> encoding_thread,
29 ScopedISVCEncoderPtr encoder);
30
31 H264Encoder(
32 const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_callback,
33 int32_t bits_per_second);
34
35 private:
36 // VideoTrackRecorder::Encoder implementation.
37 ~H264Encoder() override;
38 void EncodeOnEncodingTaskRunner(scoped_refptr<media::VideoFrame> frame,
39 base::TimeTicks capture_timestamp) override;
40
41 void ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size);
42
43 // |openh264_encoder_| is a special scoped pointer to guarantee proper
44 // destruction, also when reconfiguring due to parameters change. Only used on
45 // VideoTrackRecorder::Encoder::encoding_thread_.
46 gfx::Size configured_size_;
47 ScopedISVCEncoderPtr openh264_encoder_;
48
49 // The |VideoFrame::timestamp()| of the first received frame. Only used on
50 // VideoTrackRecorder::Encoder::encoding_thread_.
51 base::TimeTicks first_frame_timestamp_;
52
53 DISALLOW_COPY_AND_ASSIGN(H264Encoder);
54 };
55
56 } // namespace content
57
58 #endif // CONTENT_RENDERER_MEDIA_RECORDER_H264_ENCODER_H_
OLDNEW
« no previous file with comments | « content/renderer/BUILD.gn ('k') | content/renderer/media_recorder/h264_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698