MediaController_server_g.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #ifndef __MEDIACONTROLLER_SERVER_G_H
  2. #define __MEDIACONTROLLER_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "MediaController_def_g.h"
  6. namespace MediaController {
  7. class MediaService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. MediaService_ServerSessionBase() { }
  11. virtual ~MediaService_ServerSessionBase() { }
  12. virtual bool IsExclusive() { return false; }
  13. virtual bool IsSessionOverlap() { return true; }
  14. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  15. {
  16. ErrorCodeEnum Error = Error_Succeed;
  17. switch (dwMessageID) {
  18. case MediaService_Method_GetVideoDeviceName:
  19. if (dwSignature == MediaService_MethodSignature_GetVideoDeviceName) {
  20. bOverlap = true;
  21. } else {
  22. Error = Error_MethodSignatureFailed;
  23. }
  24. break;
  25. case MediaService_Method_StartCamera:
  26. if (dwSignature == MediaService_MethodSignature_StartCamera) {
  27. bOverlap = true;
  28. } else {
  29. Error = Error_MethodSignatureFailed;
  30. }
  31. break;
  32. case MediaService_Method_StopCamera:
  33. if (dwSignature == MediaService_MethodSignature_StopCamera) {
  34. bOverlap = true;
  35. } else {
  36. Error = Error_MethodSignatureFailed;
  37. }
  38. break;
  39. case MediaService_Method_StartEnvCamera:
  40. if (dwSignature == MediaService_MethodSignature_StartEnvCamera) {
  41. bOverlap = true;
  42. } else {
  43. Error = Error_MethodSignatureFailed;
  44. }
  45. break;
  46. case MediaService_Method_StopEnvCamera:
  47. if (dwSignature == MediaService_MethodSignature_StopEnvCamera) {
  48. bOverlap = true;
  49. } else {
  50. Error = Error_MethodSignatureFailed;
  51. }
  52. break;
  53. case MediaService_Method_StartSpeakerRender:
  54. if (dwSignature == MediaService_MethodSignature_StartSpeakerRender) {
  55. bOverlap = true;
  56. } else {
  57. Error = Error_MethodSignatureFailed;
  58. }
  59. break;
  60. case MediaService_Method_StopSpeakerRender:
  61. if (dwSignature == MediaService_MethodSignature_StopSpeakerRender) {
  62. bOverlap = true;
  63. } else {
  64. Error = Error_MethodSignatureFailed;
  65. }
  66. break;
  67. default:
  68. Error = Error_MethodNotFound;
  69. break;
  70. }
  71. return Error;
  72. }
  73. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  74. {
  75. ErrorCodeEnum Error = Error_Succeed;
  76. switch (dwMessageID) {
  77. case MediaService_Method_GetVideoDeviceName:
  78. if (dwSignature != MediaService_MethodSignature_GetVideoDeviceName) {
  79. Error = Error_MethodSignatureFailed;
  80. }
  81. break;
  82. case MediaService_Method_StartCamera:
  83. if (dwSignature != MediaService_MethodSignature_StartCamera) {
  84. Error = Error_MethodSignatureFailed;
  85. }
  86. break;
  87. case MediaService_Method_StopCamera:
  88. if (dwSignature != MediaService_MethodSignature_StopCamera) {
  89. Error = Error_MethodSignatureFailed;
  90. }
  91. break;
  92. case MediaService_Method_StartEnvCamera:
  93. if (dwSignature != MediaService_MethodSignature_StartEnvCamera) {
  94. Error = Error_MethodSignatureFailed;
  95. }
  96. break;
  97. case MediaService_Method_StopEnvCamera:
  98. if (dwSignature != MediaService_MethodSignature_StopEnvCamera) {
  99. Error = Error_MethodSignatureFailed;
  100. }
  101. break;
  102. case MediaService_Method_StartSpeakerRender:
  103. if (dwSignature != MediaService_MethodSignature_StartSpeakerRender) {
  104. Error = Error_MethodSignatureFailed;
  105. }
  106. break;
  107. case MediaService_Method_StopSpeakerRender:
  108. if (dwSignature != MediaService_MethodSignature_StopSpeakerRender) {
  109. Error = Error_MethodSignatureFailed;
  110. }
  111. break;
  112. default:
  113. Error = Error_MethodNotFound;
  114. break;
  115. }
  116. return Error;
  117. }
  118. virtual void Handle_GetVideoDeviceName(SpReqAnsContext<MediaService_GetVideoDeviceName_Req, MediaService_GetVideoDeviceName_Ans>::Pointer ctx)
  119. {
  120. /// override by user
  121. }
  122. virtual void Handle_StartCamera(SpOnewayCallContext<MediaService_StartCamera_Info>::Pointer ctx)
  123. {
  124. /// override by user
  125. }
  126. virtual void Handle_StopCamera(SpOnewayCallContext<MediaService_StopCamera_Info>::Pointer ctx)
  127. {
  128. /// override by user
  129. }
  130. virtual void Handle_StartEnvCamera(SpReqAnsContext<MediaService_StartEnvCamera_Req, MediaService_StartEnvCamera_Ans>::Pointer ctx)
  131. {
  132. /// override by user
  133. }
  134. virtual void Handle_StopEnvCamera(SpOnewayCallContext<MediaService_StopEnvCamera_Info>::Pointer ctx)
  135. {
  136. /// override by user
  137. }
  138. virtual void Handle_StartSpeakerRender(SpOnewayCallContext<MediaService_StartSpeakerRender_Info>::Pointer ctx)
  139. {
  140. /// override by user
  141. }
  142. virtual void Handle_StopSpeakerRender(SpOnewayCallContext<MediaService_StopSpeakerRender_Info>::Pointer ctx)
  143. {
  144. /// override by user
  145. }
  146. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  147. {
  148. CAutoBuffer Buf;
  149. DWORD dwMessageID;
  150. DWORD dwMessageSignature;
  151. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  152. if (Error == Error_Succeed) {
  153. #ifdef DEBUG
  154. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  155. #else
  156. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  157. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  158. return;
  159. }
  160. #endif
  161. switch (dwMessageID) {
  162. case MediaService_Method_GetVideoDeviceName:
  163. {
  164. SpReqAnsContext<MediaService_GetVideoDeviceName_Req,MediaService_GetVideoDeviceName_Ans>::Pointer ctx;
  165. ctx.Attach(new SpReqAnsContext<MediaService_GetVideoDeviceName_Req,MediaService_GetVideoDeviceName_Ans>(pTransactionContext));
  166. SpBuffer2Object(Buf, ctx->Req);
  167. Handle_GetVideoDeviceName(ctx);
  168. }
  169. break;
  170. case MediaService_Method_StartCamera:
  171. {
  172. SpOnewayCallContext<MediaService_StartCamera_Info>::Pointer ctx;
  173. ctx.Attach(new SpOnewayCallContext<MediaService_StartCamera_Info>());
  174. SpBuffer2Object(Buf, ctx->Info);
  175. Handle_StartCamera(ctx);
  176. }
  177. break;
  178. case MediaService_Method_StopCamera:
  179. {
  180. SpOnewayCallContext<MediaService_StopCamera_Info>::Pointer ctx;
  181. ctx.Attach(new SpOnewayCallContext<MediaService_StopCamera_Info>());
  182. SpBuffer2Object(Buf, ctx->Info);
  183. Handle_StopCamera(ctx);
  184. }
  185. break;
  186. case MediaService_Method_StartEnvCamera:
  187. {
  188. SpReqAnsContext<MediaService_StartEnvCamera_Req,MediaService_StartEnvCamera_Ans>::Pointer ctx;
  189. ctx.Attach(new SpReqAnsContext<MediaService_StartEnvCamera_Req,MediaService_StartEnvCamera_Ans>(pTransactionContext));
  190. SpBuffer2Object(Buf, ctx->Req);
  191. Handle_StartEnvCamera(ctx);
  192. }
  193. break;
  194. case MediaService_Method_StopEnvCamera:
  195. {
  196. SpOnewayCallContext<MediaService_StopEnvCamera_Info>::Pointer ctx;
  197. ctx.Attach(new SpOnewayCallContext<MediaService_StopEnvCamera_Info>());
  198. SpBuffer2Object(Buf, ctx->Info);
  199. Handle_StopEnvCamera(ctx);
  200. }
  201. break;
  202. case MediaService_Method_StartSpeakerRender:
  203. {
  204. SpOnewayCallContext<MediaService_StartSpeakerRender_Info>::Pointer ctx;
  205. ctx.Attach(new SpOnewayCallContext<MediaService_StartSpeakerRender_Info>());
  206. SpBuffer2Object(Buf, ctx->Info);
  207. Handle_StartSpeakerRender(ctx);
  208. }
  209. break;
  210. case MediaService_Method_StopSpeakerRender:
  211. {
  212. SpOnewayCallContext<MediaService_StopSpeakerRender_Info>::Pointer ctx;
  213. ctx.Attach(new SpOnewayCallContext<MediaService_StopSpeakerRender_Info>());
  214. SpBuffer2Object(Buf, ctx->Info);
  215. Handle_StopSpeakerRender(ctx);
  216. }
  217. break;
  218. default:
  219. assert(0);
  220. break;
  221. }
  222. } else {
  223. pTransactionContext->SendAnswer(Error);
  224. }
  225. }
  226. };
  227. ///////////////////////////
  228. } // namespace MediaController
  229. #endif // __MEDIACONTROLLER_SERVER_G_H