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

Side by Side Diff: webrtc/api/objc/RTCPeerConnection+Stats.mm

Issue 1640993002: Update API for Objective-C RTCPeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update against master Created 4 years, 10 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 2015 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 "RTCPeerConnection+Private.h"
12
13 #import "webrtc/api/objc/RTCMediaStreamTrack+Private.h"
14 #import "webrtc/api/objc/RTCStatsReport+Private.h"
15 #import "webrtc/base/objc/NSString+StdString.h"
16
17 namespace webrtc {
18 class StatsObserverAdapter : public StatsObserver {
19 public:
20 StatsObserverAdapter(void (^completionHandler)
21 (NSArray<RTCStatsReport *> *stats)) {
22 completion_handler_ = completionHandler;
23 }
24
25 ~StatsObserverAdapter() {
26 completion_handler_ = nil;
27 }
28
29 void OnComplete(const StatsReports& reports) override {
30 NSMutableArray *stats = [NSMutableArray arrayWithCapacity:reports.size()];
31 for (const auto* report : reports) {
32 RTCStatsReport *statsReport =
33 [[RTCStatsReport alloc] initWithNativeReport:*report];
34 [stats addObject:statsReport];
35 }
36 if (completion_handler_) {
tkchin_webrtc 2016/02/10 18:54:40 in the same spirit as prior comments, assert/call/
hjon_webrtc 2016/02/11 00:25:08 Done.
37 completion_handler_(stats);
38 }
39 Block_release(completion_handler_);
tkchin_webrtc 2016/02/10 18:54:40 Don't call Block_release, just set to nil
hjon_webrtc 2016/02/11 00:25:08 Done.
40 }
41
42 private:
43 void (^completion_handler_)(NSArray *stats);
44 };
45 } // namespace webrtc
46
47 @implementation RTCPeerConnection (Stats)
48
49 - (void)statsForMediaStreamTrack:(RTCMediaStreamTrack *)mediaStreamTrack
50 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel
51 completionHandler:
52 (void (^)(NSArray<RTCStatsReport *> *stats))completionHandler {
53 rtc::scoped_refptr<webrtc::StatsObserverAdapter> observer(
54 new rtc::RefCountedObject<webrtc::StatsObserverAdapter>
55 (completionHandler));
56 webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel =
57 [[self class] nativeStatsOutputLevelForLevel:statsOutputLevel];
58 self.nativePeerConnection->GetStats(
59 observer, mediaStreamTrack.nativeTrack, nativeOutputLevel);
60 }
61
62 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698