Skip to content

Commit 455f28f

Browse files
committed
update iOS
1 parent 28aded3 commit 455f28f

File tree

10 files changed

+483
-252
lines changed

10 files changed

+483
-252
lines changed

Prj-iOS/AR-Live-Tutorial/AR-Live-Tutorial/VideoPlayer/ArPlayerViewController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ArPlayerViewController: UIViewController {
1414
@IBOutlet var modeLabel: UILabel!
1515

1616
fileprivate var liveStatus: ARLivePlayStatus = .stopped
17-
fileprivate var renderMode: ARLiveRenderMode = .hidden
17+
fileprivate var renderMode: ARLiveRenderMode = .fit
1818
/// 拉流url
1919
var pullUrl: String!
2020

@@ -44,6 +44,8 @@ class ArPlayerViewController: UIViewController {
4444
/// 设置播放器的视频渲染 View
4545
livePlayer.setRenderView(renderView)
4646
livePlayer.setRenderFill(renderMode)
47+
/// 设置视频播放模式
48+
livePlayer.setPlayMode(.live)
4749

4850
/// 设置播放器缓存自动调整的最小和最大时间 ( 单位:秒 )
4951
livePlayer.setCacheParams(1.0, maxTime: 100)

Prj-iOS/ARLiveKit/ARLiveEnumerates.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ typedef NS_ENUM(NSInteger, ARLiveVideoScaleMode) {
365365
ARLiveVideoScaleModeAuto
366366
};
367367

368+
/**
369+
* @brief 视频播放模式。
370+
*/
371+
typedef NS_ENUM(NSInteger, ARLivePlayMode) {
372+
373+
/// 直播模式 - 暂停的过程中,数据会丢失,保证实时性
374+
ARLivePlayModeLive,
375+
376+
/// 点播模式 - 暂停的过程中,数据不会丢失,恢复后会继续播放
377+
ARLivePlayModeVod
378+
};
379+
368380

369381

370382
#endif /* ARLiveEnumerates_h */

Prj-iOS/ARLiveKit/ARLivePlayer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ NS_ASSUME_NONNULL_BEGIN
7070
*/
7171
- (int)stopPlay;
7272

73+
/**
74+
* 设置视频播放模式
75+
*
76+
* @param mode 播放模式,详见 ARLivePlayMode。
77+
* @return 0方法调用成功,<0方法调用失败
78+
*/
79+
- (int)setPlayMode:(ARLivePlayMode)mode;
80+
7381
/**
7482
* 播放器是否正在播放中。
7583
*

Prj-iOS/ARLiveKit/ARLivePlayer.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ - (int)stopPlay {
292292
return -1;
293293
}
294294

295+
- (int)setPlayMode:(ARLivePlayMode)mode {
296+
/// 设置视频播放模式
297+
if (_livePlayer) {
298+
return _livePlayer->setPlayMode((anyrtc::ArLivePlayMode)mode);
299+
}
300+
return -1;
301+
}
302+
295303
- (int)isPlaying {
296304
/// 播放器是否正在播放中
297305
if (_livePlayer) {

Prj-iOS/ARLiveLibrary.xcodeproj/project.pbxproj

Lines changed: 14 additions & 250 deletions
Large diffs are not rendered by default.
Binary file not shown.

Prj-iOS/WebRTC.framework/.DS_Store

-6 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ anyLive 是 [anyRTC](https://www.anyrtc.io/) 开源的推拉流项目。采用
3131
| 系统 | 编译环境 | CPU架构 |
3232
| ----------------- | ------------------- | ---------------------- |
3333
| Android 4.4及以上 | Android Studio、NDK | armeabi-v7a、arm64-v8a |
34-
| iOS 9.0及以上 | XCode11 | arm64、armv7 |
34+
| iOS 9.0及以上 | Xcode14 | arm64 |
3535
| Windows 7及以上 | VS2015,VS2017 | x86、x86-64 |
3636

3737
### 第三方库

webrtc/rtc_base/bind.h

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
/*
2+
* Copyright 2012 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+
// Bind() is an overloaded function that converts method calls into function
12+
// objects (aka functors). The method object is captured as a scoped_refptr<> if
13+
// possible, and as a raw pointer otherwise. Any arguments to the method are
14+
// captured by value. The return value of Bind is a stateful, nullary function
15+
// object. Care should be taken about the lifetime of objects captured by
16+
// Bind(); the returned functor knows nothing about the lifetime of a non
17+
// ref-counted method object or any arguments passed by pointer, and calling the
18+
// functor with a destroyed object will surely do bad things.
19+
//
20+
// To prevent the method object from being captured as a scoped_refptr<>, you
21+
// can use Unretained. But this should only be done when absolutely necessary,
22+
// and when the caller knows the extra reference isn't needed.
23+
//
24+
// Example usage:
25+
// struct Foo {
26+
// int Test1() { return 42; }
27+
// int Test2() const { return 52; }
28+
// int Test3(int x) { return x*x; }
29+
// float Test4(int x, float y) { return x + y; }
30+
// };
31+
//
32+
// int main() {
33+
// Foo foo;
34+
// cout << rtc::Bind(&Foo::Test1, &foo)() << endl;
35+
// cout << rtc::Bind(&Foo::Test2, &foo)() << endl;
36+
// cout << rtc::Bind(&Foo::Test3, &foo, 3)() << endl;
37+
// cout << rtc::Bind(&Foo::Test4, &foo, 7, 8.5f)() << endl;
38+
// }
39+
//
40+
// Example usage of ref counted objects:
41+
// struct Bar {
42+
// int AddRef();
43+
// int Release();
44+
//
45+
// void Test() {}
46+
// void BindThis() {
47+
// // The functor passed to AsyncInvoke() will keep this object alive.
48+
// invoker.AsyncInvoke(RTC_FROM_HERE,rtc::Bind(&Bar::Test, this));
49+
// }
50+
// };
51+
//
52+
// int main() {
53+
// rtc::scoped_refptr<Bar> bar = new rtc::RefCountedObject<Bar>();
54+
// auto functor = rtc::Bind(&Bar::Test, bar);
55+
// bar = nullptr;
56+
// // The functor stores an internal scoped_refptr<Bar>, so this is safe.
57+
// functor();
58+
// }
59+
//
60+
61+
#ifndef RTC_BASE_BIND_H_
62+
#define RTC_BASE_BIND_H_
63+
64+
#include <tuple>
65+
#include <type_traits>
66+
67+
#include "api/scoped_refptr.h"
68+
#include "rtc_base/template_util.h"
69+
70+
#define NONAME
71+
72+
namespace rtc {
73+
namespace detail {
74+
// This is needed because the template parameters in Bind can't be resolved
75+
// if they're used both as parameters of the function pointer type and as
76+
// parameters to Bind itself: the function pointer parameters are exact
77+
// matches to the function prototype, but the parameters to bind have
78+
// references stripped. This trick allows the compiler to dictate the Bind
79+
// parameter types rather than deduce them.
80+
template <class T>
81+
struct identity {
82+
typedef T type;
83+
};
84+
85+
//* IsRefCounted<T>::value will be true for types that can be used in
86+
// rtc::scoped_refptr<T>, i.e. types that implements nullary functions AddRef()
87+
// and Release(), regardless of their return types. AddRef() and Release() can
88+
// be defined in T or any superclass of T.
89+
template <typename T>
90+
class IsRefCounted {
91+
// This is a complex implementation detail done with SFINAE.
92+
93+
// Define types such that sizeof(Yes) != sizeof(No).
94+
struct Yes {
95+
char dummy[1];
96+
};
97+
struct No {
98+
char dummy[2];
99+
};
100+
// Define two overloaded template functions with return types of different
101+
// size. This way, we can use sizeof() on the return type to determine which
102+
// function the compiler would have chosen. One function will be preferred
103+
// over the other if it is possible to create it without compiler errors,
104+
// otherwise the compiler will simply remove it, and default to the less
105+
// preferred function.
106+
template <typename R>
107+
static Yes test(R* r, decltype(r->AddRef(), r->Release(), 42));
108+
template <typename C>
109+
static No test(...);
110+
111+
public:
112+
// Trick the compiler to tell if it's possible to call AddRef() and Release().
113+
static const bool value = sizeof(test<T>((T*)nullptr, 42)) == sizeof(Yes);
114+
};
115+
116+
// TernaryTypeOperator is a helper class to select a type based on a static bool
117+
// value.
118+
template <bool condition, typename IfTrueT, typename IfFalseT>
119+
struct TernaryTypeOperator {};
120+
121+
template <typename IfTrueT, typename IfFalseT>
122+
struct TernaryTypeOperator<true, IfTrueT, IfFalseT> {
123+
typedef IfTrueT type;
124+
};
125+
126+
template <typename IfTrueT, typename IfFalseT>
127+
struct TernaryTypeOperator<false, IfTrueT, IfFalseT> {
128+
typedef IfFalseT type;
129+
};
130+
131+
// PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T*
132+
// otherwise.
133+
template <class T>
134+
struct PointerType {
135+
typedef typename TernaryTypeOperator<IsRefCounted<T>::value,
136+
scoped_refptr<T>,
137+
T*>::type type;
138+
};
139+
140+
template <typename T>
141+
class UnretainedWrapper {
142+
public:
143+
explicit UnretainedWrapper(T* o) : ptr_(o) {}
144+
T* get() const { return ptr_; }
145+
146+
private:
147+
T* ptr_;
148+
};
149+
150+
} // namespace detail
151+
152+
template <typename T>
153+
static inline detail::UnretainedWrapper<T> Unretained(T* o) {
154+
return detail::UnretainedWrapper<T>(o);
155+
}
156+
157+
template <class ObjectT, class MethodT, class R, typename... Args>
158+
class MethodFunctor {
159+
public:
160+
MethodFunctor(MethodT method, ObjectT* object, Args... args)
161+
: method_(method), object_(object), args_(args...) {}
162+
R operator()() const {
163+
return CallMethod(typename sequence_generator<sizeof...(Args)>::type());
164+
}
165+
166+
private:
167+
// Use sequence_generator (see template_util.h) to expand a MethodFunctor
168+
// with 2 arguments to (std::get<0>(args_), std::get<1>(args_)), for
169+
// instance.
170+
template <int... S>
171+
R CallMethod(sequence<S...>) const {
172+
return (object_->*method_)(std::get<S>(args_)...);
173+
}
174+
175+
MethodT method_;
176+
typename detail::PointerType<ObjectT>::type object_;
177+
typename std::tuple<typename std::remove_reference<Args>::type...> args_;
178+
};
179+
180+
template <class ObjectT, class MethodT, class R, typename... Args>
181+
class UnretainedMethodFunctor {
182+
public:
183+
UnretainedMethodFunctor(MethodT method,
184+
detail::UnretainedWrapper<ObjectT> object,
185+
Args... args)
186+
: method_(method), object_(object.get()), args_(args...) {}
187+
R operator()() const {
188+
return CallMethod(typename sequence_generator<sizeof...(Args)>::type());
189+
}
190+
191+
private:
192+
// Use sequence_generator (see template_util.h) to expand an
193+
// UnretainedMethodFunctor with 2 arguments to (std::get<0>(args_),
194+
// std::get<1>(args_)), for instance.
195+
template <int... S>
196+
R CallMethod(sequence<S...>) const {
197+
return (object_->*method_)(std::get<S>(args_)...);
198+
}
199+
200+
MethodT method_;
201+
ObjectT* object_;
202+
typename std::tuple<typename std::remove_reference<Args>::type...> args_;
203+
};
204+
205+
template <class FunctorT, class R, typename... Args>
206+
class Functor {
207+
public:
208+
Functor(const FunctorT& functor, Args... args)
209+
: functor_(functor), args_(args...) {}
210+
R operator()() const {
211+
return CallFunction(typename sequence_generator<sizeof...(Args)>::type());
212+
}
213+
214+
private:
215+
// Use sequence_generator (see template_util.h) to expand a Functor
216+
// with 2 arguments to (std::get<0>(args_), std::get<1>(args_)), for
217+
// instance.
218+
template <int... S>
219+
R CallFunction(sequence<S...>) const {
220+
return functor_(std::get<S>(args_)...);
221+
}
222+
223+
FunctorT functor_;
224+
typename std::tuple<typename std::remove_reference<Args>::type...> args_;
225+
};
226+
227+
#define FP_T(x) R (ObjectT::*x)(Args...)
228+
229+
template <class ObjectT, class R, typename... Args>
230+
MethodFunctor<ObjectT, FP_T(NONAME), R, Args...> Bind(
231+
FP_T(method),
232+
ObjectT* object,
233+
typename detail::identity<Args>::type... args) {
234+
return MethodFunctor<ObjectT, FP_T(NONAME), R, Args...>(method, object,
235+
args...);
236+
}
237+
238+
template <class ObjectT, class R, typename... Args>
239+
MethodFunctor<ObjectT, FP_T(NONAME), R, Args...> Bind(
240+
FP_T(method),
241+
const scoped_refptr<ObjectT>& object,
242+
typename detail::identity<Args>::type... args) {
243+
return MethodFunctor<ObjectT, FP_T(NONAME), R, Args...>(method, object.get(),
244+
args...);
245+
}
246+
247+
template <class ObjectT, class R, typename... Args>
248+
UnretainedMethodFunctor<ObjectT, FP_T(NONAME), R, Args...> Bind(
249+
FP_T(method),
250+
detail::UnretainedWrapper<ObjectT> object,
251+
typename detail::identity<Args>::type... args) {
252+
return UnretainedMethodFunctor<ObjectT, FP_T(NONAME), R, Args...>(
253+
method, object, args...);
254+
}
255+
256+
#undef FP_T
257+
#define FP_T(x) R (ObjectT::*x)(Args...) const
258+
259+
template <class ObjectT, class R, typename... Args>
260+
MethodFunctor<const ObjectT, FP_T(NONAME), R, Args...> Bind(
261+
FP_T(method),
262+
const ObjectT* object,
263+
typename detail::identity<Args>::type... args) {
264+
return MethodFunctor<const ObjectT, FP_T(NONAME), R, Args...>(method, object,
265+
args...);
266+
}
267+
template <class ObjectT, class R, typename... Args>
268+
UnretainedMethodFunctor<const ObjectT, FP_T(NONAME), R, Args...> Bind(
269+
FP_T(method),
270+
detail::UnretainedWrapper<const ObjectT> object,
271+
typename detail::identity<Args>::type... args) {
272+
return UnretainedMethodFunctor<const ObjectT, FP_T(NONAME), R, Args...>(
273+
method, object, args...);
274+
}
275+
276+
#undef FP_T
277+
#define FP_T(x) R (*x)(Args...)
278+
279+
template <class R, typename... Args>
280+
Functor<FP_T(NONAME), R, Args...> Bind(
281+
FP_T(function),
282+
typename detail::identity<Args>::type... args) {
283+
return Functor<FP_T(NONAME), R, Args...>(function, args...);
284+
}
285+
286+
#undef FP_T
287+
288+
} // namespace rtc
289+
290+
#undef NONAME
291+
292+
#endif // RTC_BASE_BIND_H_

0 commit comments

Comments
 (0)