kb_machblue_tv_service.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:24k
源码类别:

DVD

开发平台:

C/C++

  1. //*****************************************************************************
  2. //File Name: kb_machblue_tv_service.c
  3. //
  4. //Description: service function
  5. //
  6. // used by Machblue to retrieve the system's service lists
  7. // used by Machblue to retrieve a service object attributes including its present event,
  8. //     following event and event schedule list objects
  9. // used by Machblue to access and control the system' service contexts
  10. //
  11. //Author: steven
  12. //
  13. //Date:  2007.01.20
  14. //
  15. //Version:  v1.0
  16. //*****************************************************************************
  17. #include "gendef.h"
  18. #include "db.h"
  19. #include "av.h"
  20. #include "avplay.h"
  21. #include "machblue_defines.h"
  22. #include "machblue_porting_core.h"
  23. #include "machblue_tv_defines.h"
  24. #include "machblue_tv_customer.h"
  25. #include "machblue_tv_porting.h"
  26. #include "kb_machblue_client.h"
  27. #include "kb_machblue_client_data.h"
  28. #include "kb_machblue_client_define.h"
  29. /*
  30.  * ======================= TV Service List API ===========================================
  31.  */
  32. /**
  33.  * This function returns the number of service lists available on the platform.
  34.  * svl_count  < user provided int to store service list count >
  35.  
  36.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  37.  */
  38. mb_error_t mb_tv_service_list_count_get(int *svl_count)
  39. {
  40. if(svl_count==NULL)
  41. {
  42. mb_printf("n[Machblue]:Service list get list count NULL.");
  43.        return MB_FAILURE ;
  44. }
  45. *svl_count=list_last;
  46. return MB_SUCCESS;
  47. }
  48. /**
  49.  * This function retrieves a service list object from the system.
  50.  * This function is ASYNCHRONOUS. The system should send an 
  51.  * MB_TV_NR_SERVICE_LISTS_GET notification once the request is completed.
  52.  * The "All Channel" service list should always be at index 0 (MB_TV_SVL_ALL_ID).
  53.  * @see MB_TV_NR_SERVICE_LISTS_GET 
  54.  * @see MB_TV_SVL_ALL_ID
  55.  * first_svl_pos < position of the first service list to get (0 based) >
  56.  * svl_count < pointer to number of service lists to retrieve. 
  57.                                This pointer should be updated with number of service lists actually returned. >
  58.  * svl_list        < user provided list (array) of service list pointers to update >
  59.  
  60.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  61.  */
  62. mb_error_t mb_tv_service_lists_get(int first_svl_pos,int *svl_count,mb_tv_service_list_t *svl_list)
  63. {
  64. mb_args_t args;
  65. mb_error_t ret;
  66. int index;
  67.     mb_tv_service_list_t *pSvl = svl_list ;
  68. kb_movie_serviceList_t *pSlist=kb_mb_service_list_get();;
  69. if((svl_count==NULL)||(svl_list==NULL))
  70. {
  71. mb_printf("n[Machblue]:Service list get lists NULL.");
  72.        return MB_FAILURE ;
  73. }
  74.     for(index=first_svl_pos;index<*svl_count;index++)
  75.        *(pSvl++)=&pSlist[index];
  76.    
  77.     *svl_count = index - first_svl_pos;
  78. MB_TV_SVL_LIST_ARG(&args)=svl_list;
  79.     MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  80.     ret=kb_mb_notification_send(MB_TV_NR_SERVICE_LISTS_GET, &args);
  81. if(ret!=MB_SUCCESS)
  82. {
  83. mb_printf("n[Machblue]:Service list get lists send notification error.");
  84.        return MB_FAILURE ;
  85. }
  86. return MB_SUCCESS;
  87. }
  88. /**
  89.  * This function releases a service list object. 
  90.  * svl       < service list object to release >
  91.  
  92.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  93.  */
  94. mb_error_t mb_tv_svl_release(mb_tv_service_list_t svl)
  95. {
  96. return MB_SUCCESS;
  97. }
  98. /**
  99.  * This function retrieves a service list info from the system.
  100.  * svl < service list to query >
  101.  * svl_info   < service info structure to update >
  102.  
  103.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  104.  */
  105. mb_error_t mb_tv_svl_info_get(mb_tv_service_list_t svl,mb_tv_svl_info_t *svl_info)
  106. {
  107. kb_movie_serviceList_t *pSlist=(kb_movie_serviceList_t*)svl;
  108. if(svl_info==NULL||pSlist==NULL)
  109. {
  110. mb_printf("n[Machblue]:Service list get information NULL.");
  111.        return MB_FAILURE ;
  112. }
  113. *svl_info=pSlist->info;
  114. return MB_SUCCESS;
  115. }
  116. /**
  117.  * This function returns the number of services available in a service list.
  118.  * svl < service list to query >
  119.  * service_count  < pointer to int to store service count >
  120.  
  121.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  122.  */
  123. mb_error_t mb_tv_svl_service_count_get(mb_tv_service_list_t svl,int *service_count)
  124. {
  125. kb_movie_serviceList_t *pSlist=(kb_movie_serviceList_t*)svl;
  126. if((service_count==NULL)||(pSlist==NULL))
  127. {
  128. mb_printf("n[Machblue]:Service list get service count NULL.");
  129.        return MB_FAILURE ;
  130. }
  131. *service_count=(int)pSlist->count;
  132. return MB_SUCCESS;
  133. }
  134. /**
  135.  * This function retrieves service objects from a service list.
  136.  * This function is ASYNCHRONOUS. The system should send an 
  137.  * MB_TV_NR_SERVICES_GET notification once the request is completed.
  138.  * @see MB_TV_NR_SERVICES_GET
  139.  * svl < service list to retrieve service from >
  140.  * first_service_pos < position of the first service to retrieve (0 based) >
  141.  * service_count < pointer to number of service to retrieve. 
  142.                                       This pointer should be updated with number of services actually retrieved >                                       
  143.  * service_list        < user provided list (array) of service pointers to update >
  144.  
  145.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  146.  */
  147. mb_error_t mb_tv_svl_services_get(mb_tv_service_list_t svl,int first_service_pos,
  148.     int *service_count,mb_tv_service_t *service_list)
  149. {
  150. unsigned long index=0;
  151. mb_error_t ret;
  152. mb_args_t args;
  153. kb_movie_serviceList_t *pSlist=(kb_movie_serviceList_t*)svl;
  154. kb_movie_service_t **pSer=(kb_movie_service_t**)service_list;
  155. if(pSer==NULL||service_count==NULL||pSlist==NULL)
  156. {
  157. mb_printf("n[Machblue]:Service list get services NULL.");
  158. return MB_FAILURE;
  159. }
  160. for(index=first_service_pos;index-first_service_pos<*service_count&&index<pSlist->count;index++)
  161. *(pSer++)=&pSlist->services[index];
  162. *service_count=(int)(index-first_service_pos);
  163. pSer-=*service_count;
  164. MB_TV_SERVICE_LIST_ARG(&args)=pSer;
  165. MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  166. ret=kb_mb_notification_send(MB_TV_NR_SERVICES_GET, &args);
  167. if(ret!=MB_SUCCESS)
  168. {
  169. mb_printf("n[Machblue]:Service list get services send notification error.");
  170.        return MB_FAILURE ;
  171. }
  172. return MB_SUCCESS;
  173. }
  174. /*
  175.  * ======================= TV Service API ===========================================
  176.  */
  177. /**
  178.  * This function releases a service object. 
  179.  * service      < service object to release >
  180.  
  181.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  182.  */
  183. mb_error_t mb_tv_service_release(mb_tv_service_t service)
  184. {
  185. return MB_SUCCESS;
  186. }
  187. /**
  188.  * This function retrieves a service object from a service url. 
  189.  * This function is ASYNCHRONOUS. The system should send an 
  190.  * MB_TV_NR_SERVICE_GET_FROM_URL notification once the request 
  191.  * is completed.
  192.  * @see MB_TV_NR_SERVICE_GET_FROM_URL
  193.  * url < url of the service object to retrieve. The following
  194.                                    service url syntax should be used:
  195.                                    @li To get a service object from a DVB triplet: 
  196.                                    @c "dvb://network_id.transport_id.service_id"
  197.                                    @li To get a service object from an SDP url:
  198.                                    @c "sdp://hostname:port/path"
  199.                                    @li To get a service object from an RTSP url:
  200.                                    @c "rtsp://hostname:port/path" >
  201.  * service  < pointer to service object to update >
  202.  
  203.  * @return MB_SUCCESS on success MB_FAILURE otherwise.
  204.  */
  205. mb_error_t mb_tv_service_get_from_url(const mb_char_t *url,mb_tv_service_t *service)
  206. {
  207. return MB_SUCCESS;
  208. }
  209. /**
  210.  * This function retrieves a service info from the system.
  211.  * service < service to query >
  212.  * service_info   < service info structure to update >
  213.  
  214.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  215.  */
  216. mb_error_t mb_tv_service_info_get(mb_tv_service_t service,mb_tv_service_info_t *service_info)
  217. {
  218. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  219. if(service_info==NULL|pSer==NULL)
  220. {
  221. mb_printf("n[Machblue]:Service get information NULL.");
  222. return MB_FAILURE;
  223. }
  224. *service_info=pSer->info;
  225. return MB_SUCCESS;
  226. }
  227. /**
  228.  * This function retrieves a given service authorization flags.
  229.  * Note this does not indicate if the program event currently 
  230.  * running on the service is authorized. It only indicates the
  231.  * service' status.  The list of authorization flags is enumerated
  232.  * in mb_tv_authorization_flag_t.
  233.  * @see mb_tv_authorization_flag_t.
  234.  * service < service to query >
  235.  * auth_flags  < pointer to service authorization flags to update. @see mb_tv_authorization_flag_t. >
  236.  
  237.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  238.  */
  239. mb_error_t mb_tv_service_auth_flags_get(mb_tv_service_t service,unsigned int *auth_flags)
  240. {
  241. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  242. if(auth_flags==NULL||pSer==NULL)
  243. {
  244. mb_printf("n[Machblue]:Service get auth flag NULL.");
  245. return MB_FAILURE;
  246. }
  247. *auth_flags=MB_TV_AF_AUTHORIZED;
  248. return MB_SUCCESS;
  249. }
  250. /**
  251.  * This function retrieves the current event of a service. 
  252.  * This function is ASYNCHRONOUS. The system should send an 
  253.  * MB_TV_NR_SERVICE_CURRENT_EVENT_GET notification once the request 
  254.  * is completed.
  255.  * @see MB_TV_NR_SERVICE_CURRENT_EVENT_GET
  256.  * service < service to query >
  257.  * event     < pointer to event to update >
  258.  
  259.  * @return MB_SUCCESS on success MB_FAILURE otherwise.
  260.  */
  261. mb_error_t mb_tv_service_current_event_get(mb_tv_service_t service,mb_tv_event_t *event)
  262. {
  263. mb_error_t ret;
  264. mb_args_t args;
  265. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  266. kb_movie_event_t **pEvt=(kb_movie_event_t**)event;
  267. if(pEvt==NULL||pSer==NULL)
  268. {
  269. mb_printf("n[Machblue]:Service get current event NULL.");
  270. return MB_FAILURE;
  271. }
  272. *pEvt=&(pSer->current_event);
  273. #if MB_PLAYER_1_2
  274. MB_TV_EVENT_PTR_ARG(&args)=(void*)pEvt;
  275. #else
  276. MB_TV_EVENT_ARG(&args)=(long)pEvt;
  277. #endif
  278. MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  279. ret=kb_mb_notification_send(MB_TV_NR_SERVICE_CURRENT_EVENT_GET, &args);
  280. if(ret!=MB_SUCCESS)
  281. {
  282. mb_printf("n[Machblue]:Service list get current event send notification error.");
  283.        return MB_FAILURE ;
  284. }
  285. return MB_SUCCESS;
  286. }
  287. /**
  288.  * This function retrieves the following event of a service. 
  289.  * This function is ASYNCHRONOUS. The system should send an 
  290.  * MB_TV_NR_SERVICE_FOLLOWING_EVENT_GET notification once the 
  291.  * request is completed.
  292.  * @see MB_TV_NR_SERVICE_FOLLOWING_EVENT_GET
  293.  * service < service to query >
  294.  * event      < pointer to event to update >
  295.  
  296.  * @return MB_SUCCESS on success MB_FAILURE otherwise.
  297.  */
  298. mb_error_t mb_tv_service_following_event_get(mb_tv_service_t service,mb_tv_event_t *event)
  299. {
  300. mb_error_t ret;
  301. mb_args_t args;
  302. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  303. kb_movie_event_t **pEvt=(kb_movie_event_t**)event;
  304. if(pEvt==NULL||pSer==NULL)
  305. {
  306. mb_printf("n[Machblue]:Service get following event NULL.");
  307. return MB_FAILURE;
  308. }
  309. *pEvt=&(pSer->following_event);
  310. #if MB_PLAYER_1_2
  311. MB_TV_EVENT_PTR_ARG(&args)=(void*)pEvt;
  312. #else
  313. MB_TV_EVENT_ARG(&args)=(long)pEvt;
  314. #endif
  315. MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  316. ret=kb_mb_notification_send(MB_TV_NR_SERVICE_FOLLOWING_EVENT_GET, &args);
  317. if(ret!=MB_SUCCESS)
  318. {
  319. mb_printf("n[Machblue]:Service list get following event send notification error.");
  320.        return MB_FAILURE ;
  321. }
  322. return MB_SUCCESS;
  323. }
  324. /**
  325.  * This function returns an event schedule object representing a
  326.  * section of the service complete event schedule. 
  327.  * This function is ASYNCHRONOUS. The system should send an 
  328.  * MB_TV_NR_SERVICE_EVENT_SCHEDULE_GET notification once the request 
  329.  * is completed.
  330.  * @see MB_TV_NR_SERVICE_EVENT_SCHEDULE_GET
  331.  * service < service to query >
  332.  * start_time < requested start time of the event schedule query 
  333.                                       window in seconds since 01/01/1970 UTC. 
  334.                                       If set to 0 or if the requested start time is smaller 
  335.                                       than the start time of the first available event of the 
  336.                                       event schedule cache then the first available event start 
  337.                                       time should be used for the query. >
  338.  * end_time < requested end time of the event schedule query 
  339.                                       window in seconds since 01/01/1970 UTC. 
  340.                                       If set to 0 or if the requested end time is greater 
  341.                                       than the end time of the last available event of the 
  342.                                       event schedule cache then the last available event start 
  343.                                       time should be used for the query.>
  344.  * event_schedule  < pointer to event schedule object to update >
  345.  
  346.  * @return MB_SUCCESS on success MB_FAILURE otherwise.
  347.  */
  348.  #if MB_PLAYER_1_2
  349. mb_error_t mb_tv_service_event_schedule_get(mb_tv_service_t service,
  350.                                                                                        mb_time_t start_time,mb_time_t end_time,
  351.                                                                                        unsigned long timeout,mb_tv_event_schedule_t *event_schedule)
  352. #else
  353. mb_error_t mb_tv_service_event_schedule_get(mb_tv_service_t service,
  354.                                                                                        mb_time_t start_time,mb_time_t end_time,
  355.                                                                                        mb_tv_event_schedule_t *event_schedule)
  356. #endif
  357. {
  358. mb_args_t args;
  359. mb_error_t ret;
  360. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  361. kb_movie_eventSchedule_t **pSch=(kb_movie_eventSchedule_t**)event_schedule;
  362. mb_printf("n[HYF]:mb_tv_service_event_schedule_get [%d][%d].",start_time,end_time);
  363.       
  364. if((pSer==NULL)||(pSch==NULL))
  365. {
  366. mb_printf("n[Machblue]:Service get event schedule NULL.");
  367. return MB_FAILURE;
  368. }
  369. *pSch=&(pSer->evs[start_time]);
  370. MB_TV_EVS_ARG(&args)=(long)pSch;
  371. MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  372. ret=kb_mb_notification_send(MB_TV_NR_SERVICE_EVENT_SCHEDULE_GET,&args);
  373. if(ret!=MB_SUCCESS)
  374. {
  375. mb_printf("n[Machblue]:Service get event schedule send notification error.");
  376.        return MB_FAILURE;
  377. }
  378. return MB_SUCCESS;
  379. }
  380. /**
  381.  * This function retrieves the service list object containing 
  382.  * the provided object if any. If the service is a recorded or 
  383.  * vod service that has no associated service list 
  384.  * MB_TV_INVALID_SERVICE_LIST should be returned. The function also 
  385.  * retrieve the index of the service object in the service list.
  386.  * service < service to query >
  387.  * svl < pointer to service list object to update >
  388.  * index        < pointer to the service index to update >
  389.  
  390.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  391.  */
  392. mb_error_t mb_tv_service_svl_get(mb_tv_service_t service,mb_tv_service_list_t *svl,int *index)
  393. {
  394. mb_error_t ret;
  395. unsigned long serviceIndex=0,serviceCnt=0;
  396. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  397. kb_movie_serviceList_t **pSlist=(kb_movie_serviceList_t**)svl;
  398. if(index==NULL||pSlist==NULL||pSer==NULL)
  399. {
  400. mb_printf("n[Machblue]:Service get service list NULL.");
  401. return MB_FAILURE;
  402. }
  403. if(pSer->svl==NULL)
  404. {
  405. mb_printf("n[Machblue]:Service get service list NULL.");
  406. return MB_FAILURE;
  407. }
  408. *pSlist=pSer->svl;
  409. ret=mb_tv_svl_service_count_get(*pSlist,(int*)&serviceCnt);
  410. if(ret!=MB_SUCCESS)
  411. {
  412. mb_printf("n[Machblue]:Service get service count from list error.");
  413.        return MB_FAILURE;
  414. }
  415. for(serviceIndex=0;serviceIndex<serviceCnt;serviceIndex++)
  416. {
  417. if(pSer->info.id==(*pSlist)->services[serviceIndex].info.id)
  418. {
  419. *index=(int)serviceIndex;
  420. break;
  421. }
  422. }
  423. return MB_SUCCESS;
  424. }
  425. /*
  426.  * ======================= TV Service Context API ===========================================
  427.  */
  428. /**
  429.  * This function returns the number of service contexts
  430.  * available on the platform.
  431.  * svc_count  < user provided int to store service context count >
  432.  
  433.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  434.  */
  435. mb_error_t mb_tv_service_context_count_get(int *svc_count)
  436. {
  437. if(svc_count==NULL)
  438. {
  439. mb_printf("n[Machblue]:Service context get context count NULL.");
  440. return MB_FAILURE;
  441. }
  442. *svc_count=1;
  443. return MB_SUCCESS;
  444. }
  445. /**
  446.  * This function retrieves service context objects from the system.
  447.  * This function is ASYNCHRONOUS. The system should send an 
  448.  * MB_TV_NR_SERVICE_CONTEXTS_GET notification once the request is 
  449.  * completed.
  450.  * @see MB_TV_NR_SERVICE_CONTEXTS_GET
  451.  * first_sc_pos < position of the first service context to retrieve (0 based) >
  452.  * sc_count < pointer to number of service contexts to retrieve. 
  453.                                This pointer should be updated with number of service context actually retrieved >                                                                
  454.  * svc_list         < pointer to list (array) of service contexts update >
  455.  
  456.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  457.  */
  458. mb_error_t mb_tv_service_contexts_get(int first_sc_pos,int *sc_count,mb_tv_service_context_t *svc_list)
  459. {
  460. mb_error_t ret;
  461. mb_args_t args;
  462. kb_movie_serviceContext_t **pContext=(kb_movie_serviceContext_t**)svc_list;
  463. if(pContext==NULL||sc_count==NULL)
  464. {
  465. mb_printf("n[Machblue]:Service context get context list NULL.");
  466. return MB_FAILURE;
  467. }
  468. *sc_count=1;
  469. *pContext=kb_mb_service_context_get();
  470. MB_TV_SVC_LIST_ARG(&args)=pContext;
  471. MB_TV_STATUS_ARG(&args)=MB_SUCCESS;
  472.     ret=kb_mb_notification_send(MB_TV_NR_SERVICE_CONTEXTS_GET,&args);
  473. if(ret!=MB_SUCCESS)
  474. {
  475. mb_printf("n[Machblue]:Service context get context list send notification error.");
  476.        return MB_FAILURE ;
  477. }
  478. return MB_SUCCESS;
  479. }
  480. /**
  481.  * This function retrieves the service context object associated to a client if any.
  482.  * client < client handle to query >
  483.  * client_svc < pointer to service context to update with client's service context if any,
  484.                         otherwise MB_TV_INVALID_SERVICE_CONTEXT should be returned >
  485.  
  486.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  487.  */
  488. mb_error_t mb_tv_svc_get_from_client(mb_client_t client,mb_tv_service_context_t *client_svc)
  489. {
  490. kb_movie_serviceContext_t **pContext=(kb_movie_serviceContext_t**)client_svc;
  491. if(pContext==NULL)
  492. {
  493. mb_printf("n[Machblue]:Service context get context from client NULL.");
  494. return MB_FAILURE;
  495. }
  496. *pContext=kb_mb_service_context_get();
  497. return MB_SUCCESS;
  498. }
  499. /**
  500.  * This function releases a service context object. 
  501.  * svc      < service context object to release >
  502.  
  503.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  504.  */
  505. mb_error_t mb_tv_svc_release(mb_tv_service_context_t svc)
  506. {
  507. return MB_SUCCESS;
  508. }
  509. /**
  510.  * This function retrieves a service info from the system.
  511.  * svc < service to query >
  512.  * svc_info   < service context info structure to update >
  513.  
  514.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  515.  */
  516. mb_error_t mb_tv_svc_info_get(mb_tv_service_context_t svc,mb_tv_service_context_info_t *svc_info)
  517. {
  518. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  519. if(svc_info==NULL||pContext==NULL)
  520. {
  521. mb_printf("n[Machblue]:Service context get information NULL.");
  522. return MB_FAILURE;
  523. }
  524. *svc_info=pContext->info;
  525. return MB_SUCCESS;
  526. }
  527. /**
  528.  * This function gets a service context viewport attributes
  529.  * svc < service context to query >
  530.  * viewport    < pointer to viewport coordinates to update >
  531.  
  532.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  533.  */ 
  534. mb_error_t mb_tv_svc_viewport_get(mb_tv_service_context_t svc,mb_tv_viewport_t *viewport)
  535. {
  536. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  537. if(viewport==NULL||pContext==NULL)
  538. {
  539. mb_printf("n[Machblue]:Service context get viewport NULL.");
  540. return MB_FAILURE;
  541. }
  542. *viewport=pContext->viewport;
  543. return MB_SUCCESS;
  544. }
  545. /**
  546.  * This function sets a service context viewport attributes.
  547.  * svc < service context to modify >
  548.  * viewport   < pointer to viewport coordinates to set >
  549.  
  550.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  551.  */ 
  552. mb_error_t mb_tv_svc_viewport_set(mb_tv_service_context_t svc,mb_tv_viewport_t *viewport)
  553. {
  554. INT32 nLeft, nTop, nRight, nBottom;
  555. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  556. if(viewport==NULL||pContext==NULL)
  557. {
  558. mb_printf("n[Machblue]:Service context set viewport NULL.");
  559. return MB_FAILURE;
  560. }
  561. pContext->viewport =*viewport;
  562. nLeft = viewport->bounds.x;
  563. nTop = viewport->bounds.y;
  564. nRight = viewport->bounds.width;
  565. nBottom = viewport->bounds.height;
  566. KB_AVSetWindow(nLeft, nTop, nRight, nBottom);
  567. return MB_SUCCESS;
  568. }
  569. /**
  570.  * This function retrieves a service object representing 
  571.  * the service that is currently active in a service context. 
  572.  * If the context is idle, null is returned.
  573.  * svc < service context to query >
  574.  * service   < pointer to service context service to update >
  575.  
  576.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  577.  */ 
  578. mb_error_t mb_tv_svc_service_get(mb_tv_service_context_t svc,mb_tv_service_t *service)
  579. {
  580. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  581. kb_movie_service_t **pSer=(kb_movie_service_t**)service;
  582. if(pSer==NULL||pContext==NULL)
  583. {
  584. mb_printf("n[Machblue]:Service context get current service NULL.");
  585. return MB_FAILURE;
  586. }
  587. *pSer=pContext->service;
  588. //mb_printf("n[mb_tv_svc_service_get]the service name is %s n",pContext->service->info.name);
  589. return MB_SUCCESS;
  590. }
  591. /**
  592.  * This function selects a service (tune in the case of a 
  593.  * braodcast service). The currently running service if any 
  594.  * is replaced with the selected service.
  595.  * This function is ASYNCHRONOUS. The system should send an 
  596.  * MB_TV_NR_SERVICE_SELECTED or an MB_TV_NR_SERVICE_ERROR 
  597.  * notification once the request is completed.
  598.  * @see MB_TV_NR_SERVICE_SELECTED
  599.  * @see MB_TV_NR_SERVICE_ERROR
  600.  * svc < service context to modify >
  601.  * service < service to select >
  602.  * enable_streams < 1 if default streams should be enabled after service selection, 0 otherwise. >
  603.  
  604.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  605.  */ 
  606. mb_error_t mb_tv_svc_service_select(mb_tv_service_context_t svc,mb_tv_service_t service,int enable_streams)
  607. {
  608. int pPrgNO;
  609. UINT8 pPrgType ;
  610. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  611. kb_movie_service_t *pSer=(kb_movie_service_t*)service;
  612. if(pSer==NULL||pContext==NULL)
  613. {
  614. mb_printf("n[Machblue]:Service context select service NULL.");
  615. return MB_FAILURE;
  616. }
  617. if(pSer->svl->info.id!=DTVPRG)
  618. pPrgType = RADIOPRG;
  619. else
  620. pPrgType = DTVPRG;
  621. //pPrgNO = KD_GetPrgInxBySvcID(pPrgType,pSer->info.display_id);
  622. pPrgNO=KD_GetPrgInxByTsidSvcID(pPrgType,pSer->serInfo.tsID,pSer->info.display_id);
  623. KB_DTVPlayPrg(pPrgType, pPrgNO+1);
  624. //mb_printf("");
  625. return MB_SUCCESS;
  626. }
  627. /**
  628.  * This function retrieves the stream controller associated 
  629.  * to a service context.
  630.  * svc < service context to query >
  631.  * stream_controller  < pointer to service context stream controller to update >
  632.  
  633.  * @return MB_SUCCESS on success, MB_FAILURE otherwise.
  634.  */ 
  635. mb_error_t mb_tv_svc_stream_controller_get(mb_tv_service_context_t svc,mb_tv_stream_controller_t *stream_controller)
  636. {
  637. kb_movie_serviceContext_t *pContext=(kb_movie_serviceContext_t*)svc;
  638. kb_movie_streamController_t **pScontrol=(kb_movie_streamController_t**)stream_controller;
  639. if(pScontrol==NULL||pContext==NULL)
  640. {
  641. mb_printf("n[Machblue]:Service context get stream controller NULL.");
  642. return MB_FAILURE;
  643. }
  644. *pScontrol=pContext->stc;
  645. return MB_SUCCESS;
  646. }