OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #if defined(WEBRTC_IOS) | 11 #if defined(WEBRTC_IOS) |
12 | 12 |
13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 13 #import <AVFoundation/AVFoundation.h> |
tkchin_webrtc
2015/07/08 19:41:14
Don't think you need AVFoundation here anymore.
henrika_webrtc
2015/07/09 12:58:02
Done.
| |
14 #error "This file requires ARC support." | |
15 #endif | |
16 | |
17 #import <Foundation/Foundation.h> | 14 #import <Foundation/Foundation.h> |
18 #include <string.h> | 15 #include <pthread.h> |
tkchin_webrtc
2015/07/08 19:41:14
ditto no pthread bits here
henrika_webrtc
2015/07/09 12:58:02
Done.
| |
19 | 16 |
20 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
21 #include "webrtc/typedefs.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/modules/utility/interface/helpers_ios.h" | |
22 | 20 |
23 namespace webrtc { | 21 namespace webrtc { |
24 namespace test { | 22 namespace ios { |
25 | 23 |
26 // TODO(henrika): move to shared location. | 24 // TODO(henrika): move to shared location. |
27 // See https://code.google.com/p/webrtc/issues/detail?id=4773 for details. | 25 // See https://code.google.com/p/webrtc/issues/detail?id=4773 for details. |
28 NSString* NSStringFromStdString(const std::string& stdString) { | 26 NSString* NSStringFromStdString(const std::string& stdString) { |
29 // std::string may contain null termination character so we construct | 27 // std::string may contain null termination character so we construct |
30 // using length. | 28 // using length. |
31 return [[NSString alloc] initWithBytes:stdString.data() | 29 return [[NSString alloc] initWithBytes:stdString.data() |
32 length:stdString.length() | 30 length:stdString.length() |
33 encoding:NSUTF8StringEncoding]; | 31 encoding:NSUTF8StringEncoding]; |
34 } | 32 } |
35 | 33 |
36 std::string StdStringFromNSString(NSString* nsString) { | 34 std::string StdStringFromNSString(NSString* nsString) { |
37 NSData* charData = [nsString dataUsingEncoding:NSUTF8StringEncoding]; | 35 NSData* charData = [nsString dataUsingEncoding:NSUTF8StringEncoding]; |
38 return std::string(reinterpret_cast<const char*>([charData bytes]), | 36 return std::string(reinterpret_cast<const char*>([charData bytes]), |
39 [charData length]); | 37 [charData length]); |
40 } | 38 } |
41 | 39 |
42 // For iOS, resource files are added to the application bundle in the root | 40 bool CheckAndLogError(BOOL success, NSError* error) { |
43 // and not in separate folders as is the case for other platforms. This method | 41 if (!success) { |
44 // therefore removes any prepended folders and uses only the actual file name. | 42 NSString* msg = |
45 std::string IOSResourcePath(std::string name, std::string extension) { | 43 [NSString stringWithFormat:@"Error: %ld, %@", (long)error.code, |
46 @autoreleasepool { | 44 error.localizedDescription]; |
47 NSString* path = NSStringFromStdString(name); | 45 LOG(LS_ERROR) << StdStringFromNSString(msg); |
48 NSString* fileName = path.lastPathComponent; | 46 return false; |
49 NSString* fileType = NSStringFromStdString(extension); | |
50 // Get full pathname for the resource identified by the name and extension. | |
51 NSString* pathString = [[NSBundle mainBundle] pathForResource:fileName | |
52 ofType:fileType]; | |
53 return StdStringFromNSString(pathString); | |
54 } | 47 } |
48 return true; | |
55 } | 49 } |
56 | 50 |
57 } // namespace test | 51 std::string GetCurrentThreadDescription() { |
52 NSString* name = [NSString stringWithFormat:@"%@", [NSThread currentThread]]; | |
53 return StdStringFromNSString(name); | |
54 } | |
55 | |
56 } // namespace ios | |
58 } // namespace webrtc | 57 } // namespace webrtc |
59 | 58 |
60 #endif // defined(WEBRTC_IOS) | 59 #endif // defined(WEBRTC_IOS) |
OLD | NEW |