You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

597 lines
21 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2013 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. // This file contains Macros for creating proxies for webrtc MediaStream and
  11. // PeerConnection classes.
  12. // TODO(deadbeef): Move this to pc/; this is part of the implementation.
  13. //
  14. // Example usage:
  15. //
  16. // class TestInterface : public rtc::RefCountInterface {
  17. // public:
  18. // std::string FooA() = 0;
  19. // std::string FooB(bool arg1) const = 0;
  20. // std::string FooC(bool arg1) = 0;
  21. // };
  22. //
  23. // Note that return types can not be a const reference.
  24. //
  25. // class Test : public TestInterface {
  26. // ... implementation of the interface.
  27. // };
  28. //
  29. // BEGIN_PROXY_MAP(Test)
  30. // PROXY_SIGNALING_THREAD_DESTRUCTOR()
  31. // PROXY_METHOD0(std::string, FooA)
  32. // PROXY_CONSTMETHOD1(std::string, FooB, arg1)
  33. // PROXY_WORKER_METHOD1(std::string, FooC, arg1)
  34. // END_PROXY_MAP()
  35. //
  36. // Where the destructor and first two methods are invoked on the signaling
  37. // thread, and the third is invoked on the worker thread.
  38. //
  39. // The proxy can be created using
  40. //
  41. // TestProxy::Create(Thread* signaling_thread, Thread* worker_thread,
  42. // TestInterface*).
  43. //
  44. // The variant defined with BEGIN_SIGNALING_PROXY_MAP is unaware of
  45. // the worker thread, and invokes all methods on the signaling thread.
  46. //
  47. // The variant defined with BEGIN_OWNED_PROXY_MAP does not use
  48. // refcounting, and instead just takes ownership of the object being proxied.
  49. #ifndef API_PROXY_H_
  50. #define API_PROXY_H_
  51. #include <memory>
  52. #include <string>
  53. #include <utility>
  54. #include "api/scoped_refptr.h"
  55. #include "rtc_base/event.h"
  56. #include "rtc_base/message_handler.h"
  57. #include "rtc_base/message_queue.h"
  58. #include "rtc_base/ref_counted_object.h"
  59. #include "rtc_base/system/rtc_export.h"
  60. #include "rtc_base/thread.h"
  61. namespace rtc {
  62. class Location;
  63. }
  64. namespace webrtc {
  65. template <typename R>
  66. class ReturnType {
  67. public:
  68. template <typename C, typename M>
  69. void Invoke(C* c, M m) {
  70. r_ = (c->*m)();
  71. }
  72. template <typename C, typename M, typename T1>
  73. void Invoke(C* c, M m, T1 a1) {
  74. r_ = (c->*m)(std::move(a1));
  75. }
  76. template <typename C, typename M, typename T1, typename T2>
  77. void Invoke(C* c, M m, T1 a1, T2 a2) {
  78. r_ = (c->*m)(std::move(a1), std::move(a2));
  79. }
  80. template <typename C, typename M, typename T1, typename T2, typename T3>
  81. void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3) {
  82. r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3));
  83. }
  84. template <typename C,
  85. typename M,
  86. typename T1,
  87. typename T2,
  88. typename T3,
  89. typename T4>
  90. void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4) {
  91. r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3), std::move(a4));
  92. }
  93. template <typename C,
  94. typename M,
  95. typename T1,
  96. typename T2,
  97. typename T3,
  98. typename T4,
  99. typename T5>
  100. void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) {
  101. r_ = (c->*m)(std::move(a1), std::move(a2), std::move(a3), std::move(a4),
  102. std::move(a5));
  103. }
  104. R moved_result() { return std::move(r_); }
  105. private:
  106. R r_;
  107. };
  108. template <>
  109. class ReturnType<void> {
  110. public:
  111. template <typename C, typename M>
  112. void Invoke(C* c, M m) {
  113. (c->*m)();
  114. }
  115. template <typename C, typename M, typename T1>
  116. void Invoke(C* c, M m, T1 a1) {
  117. (c->*m)(std::move(a1));
  118. }
  119. template <typename C, typename M, typename T1, typename T2>
  120. void Invoke(C* c, M m, T1 a1, T2 a2) {
  121. (c->*m)(std::move(a1), std::move(a2));
  122. }
  123. template <typename C, typename M, typename T1, typename T2, typename T3>
  124. void Invoke(C* c, M m, T1 a1, T2 a2, T3 a3) {
  125. (c->*m)(std::move(a1), std::move(a2), std::move(a3));
  126. }
  127. void moved_result() {}
  128. };
  129. namespace internal {
  130. class RTC_EXPORT SynchronousMethodCall : public rtc::MessageData,
  131. public rtc::MessageHandler {
  132. public:
  133. explicit SynchronousMethodCall(rtc::MessageHandler* proxy);
  134. ~SynchronousMethodCall() override;
  135. void Invoke(const rtc::Location& posted_from, rtc::Thread* t);
  136. private:
  137. void OnMessage(rtc::Message*) override;
  138. rtc::Event e_;
  139. rtc::MessageHandler* proxy_;
  140. };
  141. } // namespace internal
  142. template <typename C, typename R>
  143. class MethodCall0 : public rtc::Message, public rtc::MessageHandler {
  144. public:
  145. typedef R (C::*Method)();
  146. MethodCall0(C* c, Method m) : c_(c), m_(m) {}
  147. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  148. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  149. return r_.moved_result();
  150. }
  151. private:
  152. void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); }
  153. C* c_;
  154. Method m_;
  155. ReturnType<R> r_;
  156. };
  157. template <typename C, typename R>
  158. class ConstMethodCall0 : public rtc::Message, public rtc::MessageHandler {
  159. public:
  160. typedef R (C::*Method)() const;
  161. ConstMethodCall0(C* c, Method m) : c_(c), m_(m) {}
  162. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  163. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  164. return r_.moved_result();
  165. }
  166. private:
  167. void OnMessage(rtc::Message*) { r_.Invoke(c_, m_); }
  168. C* c_;
  169. Method m_;
  170. ReturnType<R> r_;
  171. };
  172. template <typename C, typename R, typename T1>
  173. class MethodCall1 : public rtc::Message, public rtc::MessageHandler {
  174. public:
  175. typedef R (C::*Method)(T1 a1);
  176. MethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(std::move(a1)) {}
  177. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  178. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  179. return r_.moved_result();
  180. }
  181. private:
  182. void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, std::move(a1_)); }
  183. C* c_;
  184. Method m_;
  185. ReturnType<R> r_;
  186. T1 a1_;
  187. };
  188. template <typename C, typename R, typename T1>
  189. class ConstMethodCall1 : public rtc::Message, public rtc::MessageHandler {
  190. public:
  191. typedef R (C::*Method)(T1 a1) const;
  192. ConstMethodCall1(C* c, Method m, T1 a1) : c_(c), m_(m), a1_(std::move(a1)) {}
  193. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  194. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  195. return r_.moved_result();
  196. }
  197. private:
  198. void OnMessage(rtc::Message*) { r_.Invoke(c_, m_, std::move(a1_)); }
  199. C* c_;
  200. Method m_;
  201. ReturnType<R> r_;
  202. T1 a1_;
  203. };
  204. template <typename C, typename R, typename T1, typename T2>
  205. class MethodCall2 : public rtc::Message, public rtc::MessageHandler {
  206. public:
  207. typedef R (C::*Method)(T1 a1, T2 a2);
  208. MethodCall2(C* c, Method m, T1 a1, T2 a2)
  209. : c_(c), m_(m), a1_(std::move(a1)), a2_(std::move(a2)) {}
  210. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  211. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  212. return r_.moved_result();
  213. }
  214. private:
  215. void OnMessage(rtc::Message*) {
  216. r_.Invoke(c_, m_, std::move(a1_), std::move(a2_));
  217. }
  218. C* c_;
  219. Method m_;
  220. ReturnType<R> r_;
  221. T1 a1_;
  222. T2 a2_;
  223. };
  224. template <typename C, typename R, typename T1, typename T2, typename T3>
  225. class MethodCall3 : public rtc::Message, public rtc::MessageHandler {
  226. public:
  227. typedef R (C::*Method)(T1 a1, T2 a2, T3 a3);
  228. MethodCall3(C* c, Method m, T1 a1, T2 a2, T3 a3)
  229. : c_(c),
  230. m_(m),
  231. a1_(std::move(a1)),
  232. a2_(std::move(a2)),
  233. a3_(std::move(a3)) {}
  234. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  235. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  236. return r_.moved_result();
  237. }
  238. private:
  239. void OnMessage(rtc::Message*) {
  240. r_.Invoke(c_, m_, std::move(a1_), std::move(a2_), std::move(a3_));
  241. }
  242. C* c_;
  243. Method m_;
  244. ReturnType<R> r_;
  245. T1 a1_;
  246. T2 a2_;
  247. T3 a3_;
  248. };
  249. template <typename C,
  250. typename R,
  251. typename T1,
  252. typename T2,
  253. typename T3,
  254. typename T4>
  255. class MethodCall4 : public rtc::Message, public rtc::MessageHandler {
  256. public:
  257. typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4);
  258. MethodCall4(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4)
  259. : c_(c),
  260. m_(m),
  261. a1_(std::move(a1)),
  262. a2_(std::move(a2)),
  263. a3_(std::move(a3)),
  264. a4_(std::move(a4)) {}
  265. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  266. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  267. return r_.moved_result();
  268. }
  269. private:
  270. void OnMessage(rtc::Message*) {
  271. r_.Invoke(c_, m_, std::move(a1_), std::move(a2_), std::move(a3_),
  272. std::move(a4_));
  273. }
  274. C* c_;
  275. Method m_;
  276. ReturnType<R> r_;
  277. T1 a1_;
  278. T2 a2_;
  279. T3 a3_;
  280. T4 a4_;
  281. };
  282. template <typename C,
  283. typename R,
  284. typename T1,
  285. typename T2,
  286. typename T3,
  287. typename T4,
  288. typename T5>
  289. class MethodCall5 : public rtc::Message, public rtc::MessageHandler {
  290. public:
  291. typedef R (C::*Method)(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
  292. MethodCall5(C* c, Method m, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
  293. : c_(c),
  294. m_(m),
  295. a1_(std::move(a1)),
  296. a2_(std::move(a2)),
  297. a3_(std::move(a3)),
  298. a4_(std::move(a4)),
  299. a5_(std::move(a5)) {}
  300. R Marshal(const rtc::Location& posted_from, rtc::Thread* t) {
  301. internal::SynchronousMethodCall(this).Invoke(posted_from, t);
  302. return r_.moved_result();
  303. }
  304. private:
  305. void OnMessage(rtc::Message*) {
  306. r_.Invoke(c_, m_, std::move(a1_), std::move(a2_), std::move(a3_),
  307. std::move(a4_), std::move(a5_));
  308. }
  309. C* c_;
  310. Method m_;
  311. ReturnType<R> r_;
  312. T1 a1_;
  313. T2 a2_;
  314. T3 a3_;
  315. T4 a4_;
  316. T5 a5_;
  317. };
  318. // Helper macros to reduce code duplication.
  319. #define PROXY_MAP_BOILERPLATE(c) \
  320. template <class INTERNAL_CLASS> \
  321. class c##ProxyWithInternal; \
  322. typedef c##ProxyWithInternal<c##Interface> c##Proxy; \
  323. template <class INTERNAL_CLASS> \
  324. class c##ProxyWithInternal : public c##Interface { \
  325. protected: \
  326. typedef c##Interface C; \
  327. \
  328. public: \
  329. const INTERNAL_CLASS* internal() const { return c_; } \
  330. INTERNAL_CLASS* internal() { return c_; }
  331. // clang-format off
  332. // clang-format would put the semicolon alone,
  333. // leading to a presubmit error (cpplint.py)
  334. #define END_PROXY_MAP() \
  335. };
  336. // clang-format on
  337. #define SIGNALING_PROXY_MAP_BOILERPLATE(c) \
  338. protected: \
  339. c##ProxyWithInternal(rtc::Thread* signaling_thread, INTERNAL_CLASS* c) \
  340. : signaling_thread_(signaling_thread), c_(c) {} \
  341. \
  342. private: \
  343. mutable rtc::Thread* signaling_thread_;
  344. #define WORKER_PROXY_MAP_BOILERPLATE(c) \
  345. protected: \
  346. c##ProxyWithInternal(rtc::Thread* signaling_thread, \
  347. rtc::Thread* worker_thread, INTERNAL_CLASS* c) \
  348. : signaling_thread_(signaling_thread), \
  349. worker_thread_(worker_thread), \
  350. c_(c) {} \
  351. \
  352. private: \
  353. mutable rtc::Thread* signaling_thread_; \
  354. mutable rtc::Thread* worker_thread_;
  355. // Note that the destructor is protected so that the proxy can only be
  356. // destroyed via RefCountInterface.
  357. #define REFCOUNTED_PROXY_MAP_BOILERPLATE(c) \
  358. protected: \
  359. ~c##ProxyWithInternal() { \
  360. MethodCall0<c##ProxyWithInternal, void> call( \
  361. this, &c##ProxyWithInternal::DestroyInternal); \
  362. call.Marshal(RTC_FROM_HERE, destructor_thread()); \
  363. } \
  364. \
  365. private: \
  366. void DestroyInternal() { c_ = nullptr; } \
  367. rtc::scoped_refptr<INTERNAL_CLASS> c_;
  368. // Note: This doesn't use a unique_ptr, because it intends to handle a corner
  369. // case where an object's deletion triggers a callback that calls back into
  370. // this proxy object. If relying on a unique_ptr to delete the object, its
  371. // inner pointer would be set to null before this reentrant callback would have
  372. // a chance to run, resulting in a segfault.
  373. #define OWNED_PROXY_MAP_BOILERPLATE(c) \
  374. public: \
  375. ~c##ProxyWithInternal() { \
  376. MethodCall0<c##ProxyWithInternal, void> call( \
  377. this, &c##ProxyWithInternal::DestroyInternal); \
  378. call.Marshal(RTC_FROM_HERE, destructor_thread()); \
  379. } \
  380. \
  381. private: \
  382. void DestroyInternal() { delete c_; } \
  383. INTERNAL_CLASS* c_;
  384. #define BEGIN_SIGNALING_PROXY_MAP(c) \
  385. PROXY_MAP_BOILERPLATE(c) \
  386. SIGNALING_PROXY_MAP_BOILERPLATE(c) \
  387. REFCOUNTED_PROXY_MAP_BOILERPLATE(c) \
  388. public: \
  389. static rtc::scoped_refptr<c##ProxyWithInternal> Create( \
  390. rtc::Thread* signaling_thread, INTERNAL_CLASS* c) { \
  391. return new rtc::RefCountedObject<c##ProxyWithInternal>(signaling_thread, \
  392. c); \
  393. }
  394. #define BEGIN_PROXY_MAP(c) \
  395. PROXY_MAP_BOILERPLATE(c) \
  396. WORKER_PROXY_MAP_BOILERPLATE(c) \
  397. REFCOUNTED_PROXY_MAP_BOILERPLATE(c) \
  398. public: \
  399. static rtc::scoped_refptr<c##ProxyWithInternal> Create( \
  400. rtc::Thread* signaling_thread, rtc::Thread* worker_thread, \
  401. INTERNAL_CLASS* c) { \
  402. return new rtc::RefCountedObject<c##ProxyWithInternal>(signaling_thread, \
  403. worker_thread, c); \
  404. }
  405. #define BEGIN_OWNED_PROXY_MAP(c) \
  406. PROXY_MAP_BOILERPLATE(c) \
  407. WORKER_PROXY_MAP_BOILERPLATE(c) \
  408. OWNED_PROXY_MAP_BOILERPLATE(c) \
  409. public: \
  410. static std::unique_ptr<c##Interface> Create( \
  411. rtc::Thread* signaling_thread, rtc::Thread* worker_thread, \
  412. std::unique_ptr<INTERNAL_CLASS> c) { \
  413. return std::unique_ptr<c##Interface>(new c##ProxyWithInternal( \
  414. signaling_thread, worker_thread, c.release())); \
  415. }
  416. #define PROXY_SIGNALING_THREAD_DESTRUCTOR() \
  417. private: \
  418. rtc::Thread* destructor_thread() const { return signaling_thread_; } \
  419. \
  420. public: // NOLINTNEXTLINE
  421. #define PROXY_WORKER_THREAD_DESTRUCTOR() \
  422. private: \
  423. rtc::Thread* destructor_thread() const { return worker_thread_; } \
  424. \
  425. public: // NOLINTNEXTLINE
  426. #define PROXY_METHOD0(r, method) \
  427. r method() override { \
  428. MethodCall0<C, r> call(c_, &C::method); \
  429. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  430. }
  431. #define PROXY_CONSTMETHOD0(r, method) \
  432. r method() const override { \
  433. ConstMethodCall0<C, r> call(c_, &C::method); \
  434. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  435. }
  436. #define PROXY_METHOD1(r, method, t1) \
  437. r method(t1 a1) override { \
  438. MethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
  439. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  440. }
  441. #define PROXY_CONSTMETHOD1(r, method, t1) \
  442. r method(t1 a1) const override { \
  443. ConstMethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
  444. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  445. }
  446. #define PROXY_METHOD2(r, method, t1, t2) \
  447. r method(t1 a1, t2 a2) override { \
  448. MethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
  449. std::move(a2)); \
  450. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  451. }
  452. #define PROXY_METHOD3(r, method, t1, t2, t3) \
  453. r method(t1 a1, t2 a2, t3 a3) override { \
  454. MethodCall3<C, r, t1, t2, t3> call(c_, &C::method, std::move(a1), \
  455. std::move(a2), std::move(a3)); \
  456. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  457. }
  458. #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \
  459. r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \
  460. MethodCall4<C, r, t1, t2, t3, t4> call(c_, &C::method, std::move(a1), \
  461. std::move(a2), std::move(a3), \
  462. std::move(a4)); \
  463. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  464. }
  465. #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \
  466. r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \
  467. MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_, &C::method, std::move(a1), \
  468. std::move(a2), std::move(a3), \
  469. std::move(a4), std::move(a5)); \
  470. return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
  471. }
  472. // Define methods which should be invoked on the worker thread.
  473. #define PROXY_WORKER_METHOD0(r, method) \
  474. r method() override { \
  475. MethodCall0<C, r> call(c_, &C::method); \
  476. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  477. }
  478. #define PROXY_WORKER_CONSTMETHOD0(r, method) \
  479. r method() const override { \
  480. ConstMethodCall0<C, r> call(c_, &C::method); \
  481. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  482. }
  483. #define PROXY_WORKER_METHOD1(r, method, t1) \
  484. r method(t1 a1) override { \
  485. MethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
  486. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  487. }
  488. #define PROXY_WORKER_CONSTMETHOD1(r, method, t1) \
  489. r method(t1 a1) const override { \
  490. ConstMethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
  491. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  492. }
  493. #define PROXY_WORKER_METHOD2(r, method, t1, t2) \
  494. r method(t1 a1, t2 a2) override { \
  495. MethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
  496. std::move(a2)); \
  497. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  498. }
  499. #define PROXY_WORKER_CONSTMETHOD2(r, method, t1, t2) \
  500. r method(t1 a1, t2 a2) const override { \
  501. ConstMethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
  502. std::move(a2)); \
  503. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  504. }
  505. #define PROXY_WORKER_METHOD3(r, method, t1, t2, t3) \
  506. r method(t1 a1, t2 a2, t3 a3) override { \
  507. MethodCall3<C, r, t1, t2, t3> call(c_, &C::method, std::move(a1), \
  508. std::move(a2), std::move(a3)); \
  509. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  510. }
  511. #define PROXY_WORKER_CONSTMETHOD3(r, method, t1, t2) \
  512. r method(t1 a1, t2 a2, t3 a3) const override { \
  513. ConstMethodCall3<C, r, t1, t2, t3> call(c_, &C::method, std::move(a1), \
  514. std::move(a2), std::move(a3)); \
  515. return call.Marshal(RTC_FROM_HERE, worker_thread_); \
  516. }
  517. } // namespace webrtc
  518. #endif // API_PROXY_H_