OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 24 matching lines...) Expand all Loading... |
35 #import "RTCMediaStream.h" | 35 #import "RTCMediaStream.h" |
36 #import "RTCPair.h" | 36 #import "RTCPair.h" |
37 #import "RTCPeerConnectionInterface.h" | 37 #import "RTCPeerConnectionInterface.h" |
38 #import "RTCVideoCapturer.h" | 38 #import "RTCVideoCapturer.h" |
39 #import "RTCAVFoundationVideoSource.h" | 39 #import "RTCAVFoundationVideoSource.h" |
40 | 40 |
41 #import "ARDAppEngineClient.h" | 41 #import "ARDAppEngineClient.h" |
42 #import "ARDCEODTURNClient.h" | 42 #import "ARDCEODTURNClient.h" |
43 #import "ARDJoinResponse.h" | 43 #import "ARDJoinResponse.h" |
44 #import "ARDMessageResponse.h" | 44 #import "ARDMessageResponse.h" |
| 45 #import "ARDSDPUtils.h" |
45 #import "ARDSignalingMessage.h" | 46 #import "ARDSignalingMessage.h" |
46 #import "ARDUtilities.h" | 47 #import "ARDUtilities.h" |
47 #import "ARDWebSocketChannel.h" | 48 #import "ARDWebSocketChannel.h" |
48 #import "RTCICECandidate+JSON.h" | 49 #import "RTCICECandidate+JSON.h" |
49 #import "RTCSessionDescription+JSON.h" | 50 #import "RTCSessionDescription+JSON.h" |
50 | 51 |
51 | 52 |
52 static NSString * const kARDDefaultSTUNServerUrl = | 53 static NSString * const kARDDefaultSTUNServerUrl = |
53 @"stun:stun.l.google.com:19302"; | 54 @"stun:stun.l.google.com:19302"; |
54 // TODO(tkchin): figure out a better username for CEOD statistics. | 55 // TODO(tkchin): figure out a better username for CEOD statistics. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 NSDictionary *userInfo = @{ | 338 NSDictionary *userInfo = @{ |
338 NSLocalizedDescriptionKey: @"Failed to create session description.", | 339 NSLocalizedDescriptionKey: @"Failed to create session description.", |
339 }; | 340 }; |
340 NSError *sdpError = | 341 NSError *sdpError = |
341 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain | 342 [[NSError alloc] initWithDomain:kARDAppClientErrorDomain |
342 code:kARDAppClientErrorCreateSDP | 343 code:kARDAppClientErrorCreateSDP |
343 userInfo:userInfo]; | 344 userInfo:userInfo]; |
344 [_delegate appClient:self didError:sdpError]; | 345 [_delegate appClient:self didError:sdpError]; |
345 return; | 346 return; |
346 } | 347 } |
| 348 // Prefer H264 if available. |
| 349 RTCSessionDescription *sdpPreferringH264 = |
| 350 [ARDSDPUtils descriptionForDescription:sdp |
| 351 preferredVideoCodec:@"H264"]; |
347 [_peerConnection setLocalDescriptionWithDelegate:self | 352 [_peerConnection setLocalDescriptionWithDelegate:self |
348 sessionDescription:sdp]; | 353 sessionDescription:sdpPreferringH264]; |
349 ARDSessionDescriptionMessage *message = | 354 ARDSessionDescriptionMessage *message = |
350 [[ARDSessionDescriptionMessage alloc] initWithDescription:sdp]; | 355 [[ARDSessionDescriptionMessage alloc] |
| 356 initWithDescription:sdpPreferringH264]; |
351 [self sendSignalingMessage:message]; | 357 [self sendSignalingMessage:message]; |
352 }); | 358 }); |
353 } | 359 } |
354 | 360 |
355 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 361 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
356 didSetSessionDescriptionWithError:(NSError *)error { | 362 didSetSessionDescriptionWithError:(NSError *)error { |
357 dispatch_async(dispatch_get_main_queue(), ^{ | 363 dispatch_async(dispatch_get_main_queue(), ^{ |
358 if (error) { | 364 if (error) { |
359 NSLog(@"Failed to set session description. Error: %@", error); | 365 NSLog(@"Failed to set session description. Error: %@", error); |
360 [self disconnect]; | 366 [self disconnect]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // Processes the given signaling message based on its type. | 440 // Processes the given signaling message based on its type. |
435 - (void)processSignalingMessage:(ARDSignalingMessage *)message { | 441 - (void)processSignalingMessage:(ARDSignalingMessage *)message { |
436 NSParameterAssert(_peerConnection || | 442 NSParameterAssert(_peerConnection || |
437 message.type == kARDSignalingMessageTypeBye); | 443 message.type == kARDSignalingMessageTypeBye); |
438 switch (message.type) { | 444 switch (message.type) { |
439 case kARDSignalingMessageTypeOffer: | 445 case kARDSignalingMessageTypeOffer: |
440 case kARDSignalingMessageTypeAnswer: { | 446 case kARDSignalingMessageTypeAnswer: { |
441 ARDSessionDescriptionMessage *sdpMessage = | 447 ARDSessionDescriptionMessage *sdpMessage = |
442 (ARDSessionDescriptionMessage *)message; | 448 (ARDSessionDescriptionMessage *)message; |
443 RTCSessionDescription *description = sdpMessage.sessionDescription; | 449 RTCSessionDescription *description = sdpMessage.sessionDescription; |
| 450 // Prefer H264 if available. |
| 451 RTCSessionDescription *sdpPreferringH264 = |
| 452 [ARDSDPUtils descriptionForDescription:description |
| 453 preferredVideoCodec:@"H264"]; |
444 [_peerConnection setRemoteDescriptionWithDelegate:self | 454 [_peerConnection setRemoteDescriptionWithDelegate:self |
445 sessionDescription:description]; | 455 sessionDescription:sdpPreferringH264]; |
446 break; | 456 break; |
447 } | 457 } |
448 case kARDSignalingMessageTypeCandidate: { | 458 case kARDSignalingMessageTypeCandidate: { |
449 ARDICECandidateMessage *candidateMessage = | 459 ARDICECandidateMessage *candidateMessage = |
450 (ARDICECandidateMessage *)message; | 460 (ARDICECandidateMessage *)message; |
451 [_peerConnection addICECandidate:candidateMessage.candidate]; | 461 [_peerConnection addICECandidate:candidateMessage.candidate]; |
452 break; | 462 break; |
453 } | 463 } |
454 case kARDSignalingMessageTypeBye: | 464 case kARDSignalingMessageTypeBye: |
455 // Other client disconnected. | 465 // Other client disconnected. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 code:kARDAppClientErrorInvalidRoom | 643 code:kARDAppClientErrorInvalidRoom |
634 userInfo:@{ | 644 userInfo:@{ |
635 NSLocalizedDescriptionKey: @"Invalid room.", | 645 NSLocalizedDescriptionKey: @"Invalid room.", |
636 }]; | 646 }]; |
637 break; | 647 break; |
638 } | 648 } |
639 return error; | 649 return error; |
640 } | 650 } |
641 | 651 |
642 @end | 652 @end |
OLD | NEW |