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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm

Issue 2966023002: Injectable Obj-C video codecs (Closed)
Patch Set: Fix some issues from comments. Created 3 years, 5 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 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #import <WebRTC/RTCVideoCodec.h>
12 #import <WebRTC/RTCVideoCodecFactory.h>
13
14 #import "RTCVideoCodec+Private.h"
15 #include "webrtc/sdk/objc/Framework/Classes/Common/helpers.h"
16
17 // Describe a codec
18 @implementation RTCVideoCodecInfo
19
20 @synthesize payload = _payload;
21 @synthesize name = _name;
22 @synthesize parameters = _parameters;
23
24 - (instancetype)initWithPayload:(int)payload
25 name:(NSString *)name
26 parameters:(NSDictionary<NSString *, NSString *> *)paramete rs {
27 if (self = [super init]) {
28 _payload = payload;
29 _name = name;
30 _parameters = parameters;
31 }
32
33 return self;
34 }
35
36 - (instancetype)initWithVideoCodec:(cricket::VideoCodec)videoCodec {
37 NSMutableDictionary *params = [NSMutableDictionary dictionary];
38 for (auto it = videoCodec.params.begin(); it != videoCodec.params.end(); ++it) {
39 [params setObject:webrtc::ios::NSStringFromStdString(it->second)
40 forKey:webrtc::ios::NSStringFromStdString(it->first)];
41 }
42 return [self initWithPayload:videoCodec.id
43 name:webrtc::ios::NSStringFromStdString(videoCodec.nam e)
44 parameters:params];
45 }
46
47 - (cricket::VideoCodec)toCpp {
48 cricket::VideoCodec codec(webrtc::ios::StdStringFromNSString(_name));
49 for (NSString *paramKey in [_parameters allKeys]) {
50 codec.SetParam(webrtc::ios::StdStringFromNSString(paramKey),
51 webrtc::ios::StdStringFromNSString(_parameters[paramKey]));
52 }
53
54 return codec;
55 }
56
57 @end
58
59 // Settings for encoder
60 @implementation RTCVideoEncoderSettings
61
62 @synthesize name = _name;
63 @synthesize width = _width;
64 @synthesize height = _height;
65 @synthesize startBitrate = _startBitrate;
66 @synthesize maxBitrate = _maxBitrate;
67 @synthesize minBitrate = _minBitrate;
68 @synthesize targetBitrate = _targetBitrate;
69 @synthesize maxFramerate = _maxFramerate;
70 @synthesize qpMax = _qpMax;
71
72 - (instancetype)initWithVideoCodec:(const webrtc::VideoCodec *__nullable)videoCo dec {
73 if (self = [super init]) {
74 if (videoCodec) {
75 rtc::Optional<const char *> codecName = CodecTypeToPayloadName(videoCodec- >codecType);
76 if (codecName) {
77 _name = [NSString stringWithUTF8String:codecName.value()];
78 }
79
80 _width = videoCodec->width;
81 _height = videoCodec->height;
82 _startBitrate = videoCodec->startBitrate;
83 _maxBitrate = videoCodec->maxBitrate;
84 _minBitrate = videoCodec->minBitrate;
85 _targetBitrate = videoCodec->targetBitrate;
86 _maxFramerate = videoCodec->maxFramerate;
87 _qpMax = videoCodec->qpMax;
88 }
89 }
90
91 return self;
92 }
93
94 - (webrtc::VideoCodec *)toCpp {
95 webrtc::VideoCodec *codecSettings = new webrtc::VideoCodec;
96
97 rtc::Optional<webrtc::VideoCodecType> codecType =
98 webrtc::PayloadNameToCodecType(webrtc::ios::StdStringFromNSString(_name));
99 if (codecType) {
100 codecSettings->codecType = codecType.value();
101 }
102
103 codecSettings->width = _width;
104 codecSettings->height = _height;
105 codecSettings->startBitrate = _startBitrate;
106 codecSettings->maxBitrate = _maxBitrate;
107 codecSettings->minBitrate = _minBitrate;
108 codecSettings->targetBitrate = _targetBitrate;
109 codecSettings->maxFramerate = _maxFramerate;
110 codecSettings->qpMax = _qpMax;
111
112 return codecSettings;
113 }
114
115 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698