Chromium Code Reviews| Index: webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m |
| diff --git a/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m b/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m |
| index 3a8a578dc68fccf47cab303d315866749a494893..9552936924519e16f38f5ff814e3853b9d6d7c08 100644 |
| --- a/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m |
| +++ b/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m |
| @@ -27,7 +27,9 @@ |
| [NSMutableArray arrayWithArray: |
| [sdpString componentsSeparatedByString:lineSeparator]]; |
| NSInteger mLineIndex = -1; |
| - NSString *codecRtpMap = nil; |
| + // An array with all payload types with name |codec|. The payload types are |
| + // integers in the range 96-127, but they are stored as strings here. |
| + NSMutableArray *codecPayloadTypes = [[NSMutableArray alloc] init]; |
| // a=rtpmap:<payload type> <encoding name>/<clock rate> |
| // [/<encoding parameters>] |
| NSString *pattern = |
| @@ -36,8 +38,7 @@ |
| [NSRegularExpression regularExpressionWithPattern:pattern |
| options:0 |
| error:nil]; |
| - for (NSInteger i = 0; (i < lines.count) && (mLineIndex == -1 || !codecRtpMap); |
| - ++i) { |
| + for (NSInteger i = 0; i < lines.count; ++i) { |
| NSString *line = lines[i]; |
| if ([line hasPrefix:@"m=video"]) { |
| mLineIndex = i; |
| @@ -48,17 +49,16 @@ |
| options:0 |
| range:NSMakeRange(0, line.length)]; |
| if (codecMatches) { |
| - codecRtpMap = |
| - [line substringWithRange:[codecMatches rangeAtIndex:1]]; |
| - continue; |
| + [codecPayloadTypes |
| + addObject:[line substringWithRange:[codecMatches rangeAtIndex:1]]]; |
| } |
| } |
| if (mLineIndex == -1) { |
|
daniela-webrtc
2016/11/21 16:23:00
can we extract the check for the "m=video" even be
magjed_webrtc
2016/11/22 14:40:24
Done, I extracted finding the "m=video" line out f
|
| RTCLog(@"No m=video line, so can't prefer %@", codec); |
| return description; |
| } |
| - if (!codecRtpMap) { |
| - RTCLog(@"No rtpmap for %@", codec); |
| + if ([codecPayloadTypes count] == 0) { |
| + RTCLog(@"No payload types with name %@", codec); |
| return description; |
| } |
| NSArray *origMLineParts = |
| @@ -71,9 +71,9 @@ |
| [newMLineParts addObject:origMLineParts[origPartIndex++]]; |
| [newMLineParts addObject:origMLineParts[origPartIndex++]]; |
| [newMLineParts addObject:origMLineParts[origPartIndex++]]; |
| - [newMLineParts addObject:codecRtpMap]; |
| + [newMLineParts addObjectsFromArray:codecPayloadTypes]; |
|
daniela-webrtc
2016/11/21 16:23:00
Perhaps we can extend the usage of methods of NSMu
magjed_webrtc
2016/11/22 14:40:24
Done, I tried my best to make it cleaner.
|
| for (; origPartIndex < origMLineParts.count; ++origPartIndex) { |
| - if (![codecRtpMap isEqualToString:origMLineParts[origPartIndex]]) { |
| + if (![codecPayloadTypes containsObject:origMLineParts[origPartIndex]]) { |
| [newMLineParts addObject:origMLineParts[origPartIndex]]; |
| } |
| } |