payload.c
上传用户:biaoge6808
上传日期:2007-08-15
资源大小:42k
文件大小:13k
源码类别:

多媒体

开发平台:

C/C++

  1. #ifdef __cplusplus
  2. extern "C" {
  3. #endif
  4. /*
  5.   NOTICE:
  6.   This document contains information that is proprietary to RADVISION LTD..
  7.   No part of this publication may be reproduced in any form whatsoever without
  8.   written prior approval by RADVISION LTD..
  9.     RADVISION LTD. reserves the right to revise this publication and make changes
  10.     without obligation to notify any person of such revisions or changes.
  11. */
  12. #include <rvcommon.h>
  13. #include "bitfield.h"
  14. #include <li.h>
  15. #include "rtp.h"
  16. #include "payload.h"
  17. RVAPI
  18. INT32 RVCALLCONV rtpPCMUPack(
  19.                               IN    void*buf,
  20.                               IN    INT32 len,
  21.                               IN    rtpParam*p,
  22.                               IN    void*param)
  23. {
  24.   if(buf || len || param);
  25.     p->payload=PCMU;
  26.     return 0;
  27. }
  28. RVAPI
  29. INT32 RVCALLCONV rtpPCMUUnpack(
  30.                                 OUT void*buf,
  31.                                 IN  INT32 len,
  32.                                 OUT rtpParam*p,
  33.                                 OUT void*param)
  34. {
  35.   if(buf || len || p || param);
  36.     return 0;
  37. }
  38. RVAPI
  39. INT32 RVCALLCONV rtpPCMUGetHeaderLength(void)
  40. {
  41.     return rtpGetHeaderLength();
  42. }
  43. RVAPI
  44. INT32 RVCALLCONV rtpPCMAPack(
  45.                               IN    void*buf,
  46.                               IN    INT32 len,
  47.                               IN    rtpParam*p,
  48.                               IN    void*param)
  49. {
  50.   if(buf || len || param);
  51.     p->payload=PCMA;
  52.     return 0;
  53. }
  54. RVAPI
  55. INT32 RVCALLCONV rtpPCMAUnpack(
  56.                                 OUT     void*buf,
  57.                                 IN  INT32 len,
  58.                                 OUT     rtpParam*p,
  59.                                 OUT void*param)
  60. {
  61.   if(buf || len || p || param);
  62.     return 0;
  63. }
  64. RVAPI
  65. INT32 RVCALLCONV rtpPCMAGetHeaderLength(void)
  66. {
  67.     return rtpGetHeaderLength();
  68. }
  69. RVAPI
  70. INT32 RVCALLCONV rtpG722Pack(
  71.                               IN    void*buf,
  72.                               IN    INT32 len,
  73.                               IN    rtpParam*p,
  74.                               IN    void*param)
  75. {
  76.   if(buf || len || param);
  77.     p->payload=G722;
  78.     return 0;
  79. }
  80. RVAPI
  81. INT32 RVCALLCONV rtpG722Unpack(
  82.                                 OUT     void*buf,
  83.                                 IN  INT32 len,
  84.                                 OUT rtpParam*p,
  85.                                 OUT void*param)
  86. {
  87.   if(buf || len || p || param);
  88.     return 0;
  89. }
  90. RVAPI
  91. INT32 RVCALLCONV rtpG722GetHeaderLength(void)
  92. {
  93.     return rtpGetHeaderLength();
  94. }
  95. RVAPI
  96. INT32 RVCALLCONV rtpG728Pack(
  97.                               IN    void*buf,
  98.                               IN    INT32 len,
  99.                               IN    rtpParam*p,
  100.                               IN    void*param)
  101. {
  102.   if(buf || len || param);
  103.     p->payload=G728;
  104.     return 0;
  105. }
  106. RVAPI
  107. INT32 RVCALLCONV rtpG728Unpack(
  108.                                 OUT     void*buf,
  109.                                 IN  INT32 len,
  110.                                 OUT rtpParam*p,
  111.                                 OUT void*param)
  112. {
  113.   if(buf || len || p || param);
  114.     return 0;
  115. }
  116. RVAPI
  117. INT32 RVCALLCONV rtpG728GetHeaderLength(void)
  118. {
  119.     return rtpGetHeaderLength();
  120. }
  121. RVAPI
  122. INT32 RVCALLCONV rtpG729Pack(
  123.                               IN    void*buf,
  124.                               IN    INT32 len,
  125.                               IN    rtpParam*p,
  126.                               IN    void*param)
  127. {
  128.   if(buf || len || param);
  129.     p->payload=G729;
  130.     return 0;
  131. }
  132. RVAPI
  133. INT32 RVCALLCONV rtpG729Unpack(
  134.                                 OUT     void*buf,
  135.                                 IN  INT32 len,
  136.                                 OUT rtpParam*p,
  137.                                 OUT void*param)
  138. {
  139.   if(buf || len || p || param);
  140.     return 0;
  141. }
  142. RVAPI
  143. INT32 RVCALLCONV rtpG729GetHeaderLength(void)
  144. {
  145.     return rtpGetHeaderLength();
  146. }
  147. RVAPI
  148. INT32 RVCALLCONV rtpG7231Pack(
  149.                               IN    void*buf,
  150.                               IN    INT32 len,
  151.                               IN    rtpParam*p,
  152.                               IN    void*param)
  153. {
  154.   if(buf || len || param);
  155.     p->payload=G7231;
  156.     return 0;
  157. }
  158. RVAPI
  159. INT32 RVCALLCONV rtpG7231Unpack(
  160.                                 OUT     void*buf,
  161.                                 IN  INT32 len,
  162.                                 OUT rtpParam*p,
  163.                                 OUT void*param)
  164. {
  165.  if(buf || len || param || p);
  166.     return 0;
  167. }
  168. RVAPI
  169. INT32 RVCALLCONV rtpG7231GetHeaderLength(void)
  170. {
  171.     return rtpGetHeaderLength();
  172. }
  173. RVAPI
  174. INT32 RVCALLCONV rtpH261Pack(
  175.                               IN    void*buf,
  176.                               IN    INT32 len,
  177.                               IN    rtpParam*p,
  178.                               IN    void*param)
  179. {
  180.     H261param*h261=(H261param*)param;
  181.     UINT32*hPtr;
  182.     p->sByte-=4;
  183.     hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  184.     hPtr[0]=bitfieldSet(0,h261->v,24,1);
  185.     hPtr[0]=bitfieldSet(hPtr[0],h261->i,25,1);
  186.     if(len);
  187.     if (h261->gobN)
  188.     {
  189.         hPtr[0]=bitfieldSet(hPtr[0],h261->vMvd,0,5);
  190.         hPtr[0]=bitfieldSet(hPtr[0],h261->hMvd,5,5);
  191.         hPtr[0]=bitfieldSet(hPtr[0],h261->quant,10,5);
  192.         hPtr[0]=bitfieldSet(hPtr[0],h261->mbaP,15,5);
  193.         hPtr[0]=bitfieldSet(hPtr[0],h261->gobN,20,4);
  194.     }
  195.     hPtr[0]=bitfieldSet(hPtr[0],h261->eBit,26,3);
  196.     hPtr[0]=bitfieldSet(hPtr[0],h261->sBit,29,3);
  197.     p->payload=H261;
  198.     liConvertHeader2l((BYTE*)hPtr,0,1);
  199.     return 0;
  200. }
  201. RVAPI
  202. INT32 RVCALLCONV rtpH261Unpack(
  203.                                 OUT void*buf,
  204.                                 IN  INT32 len,
  205.                                 OUT rtpParam*p,
  206.                                 OUT void*param)
  207. {
  208.     H261param*h261=(H261param*)param;
  209.     UINT32*hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  210.     if(len);
  211.     p->sByte+=4;
  212.     liConvertHeader2h((BYTE*)hPtr,0,1);
  213.     h261->vMvd=bitfieldGet(hPtr[0],0,5);
  214.     h261->hMvd=bitfieldGet(hPtr[0],5,5);
  215.     h261->quant=bitfieldGet(hPtr[0],10,5);
  216.     h261->mbaP=bitfieldGet(hPtr[0],15,5);
  217.     h261->gobN=bitfieldGet(hPtr[0],20,4);
  218.     h261->v=bitfieldGet(hPtr[0],24,1);
  219.     h261->i=bitfieldGet(hPtr[0],25,1);
  220.     h261->eBit=bitfieldGet(hPtr[0],26,3);
  221.     h261->sBit=bitfieldGet(hPtr[0],29,3);
  222.     return 0;
  223. }
  224. RVAPI
  225. INT32 RVCALLCONV rtpH261GetHeaderLength()
  226. {
  227.     return rtpGetHeaderLength()+4;
  228. }
  229. INT32 RVCALLCONV rtpH263Pack(
  230.                               IN    void*buf,
  231.                               IN    INT32 len,
  232.                               IN    rtpParam*p,
  233.                               IN    void*param)
  234. {
  235.     H263param*h263=(H263param*)param;
  236.     UINT32*hPtr=NULL;
  237.     int dwords=0;
  238.     if(len);
  239.     if (h263->p)
  240.     {
  241.         dwords=1;
  242.         p->sByte-=4;
  243.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  244.         hPtr[0]=bitfieldSet(0,h263->dbq,11,2);
  245.         hPtr[0]=bitfieldSet(hPtr[0],h263->trb,8,3);
  246.         hPtr[0]=bitfieldSet(hPtr[0],h263->tr,0,8);
  247.     }
  248.     if (h263->f)
  249.     {
  250.         dwords+=2;
  251.         p->sByte-=8;
  252.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  253.         hPtr[0]=bitfieldSet(0,h263->mbaP,0,8);
  254.         hPtr[0]=bitfieldSet(hPtr[0],h263->gobN,8,5);
  255.         hPtr[0]=bitfieldSet(hPtr[0],h263->quant,16,5);
  256.         hPtr[1]=bitfieldSet(      0,h263->vMv2, 0,8);
  257.         hPtr[1]=bitfieldSet(hPtr[1],h263->hMv2, 8,8);
  258.         hPtr[1]=bitfieldSet(hPtr[1],h263->vMv1,16,8);
  259.         hPtr[1]=bitfieldSet(hPtr[1],h263->hMv1,24,8);
  260.     }
  261.     if (!h263->f && !h263->p)
  262.     {
  263.         dwords=1;
  264.         p->sByte-=4;
  265.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  266.         hPtr[0]=0;
  267.     }
  268.     hPtr[0]=bitfieldSet(hPtr[0],h263->f,31,1);
  269.     hPtr[0]=bitfieldSet(hPtr[0],h263->p,30,1);
  270.     hPtr[0]=bitfieldSet(hPtr[0],h263->sBit,27,3);
  271.     hPtr[0]=bitfieldSet(hPtr[0],h263->eBit,24,3);
  272.     hPtr[0]=bitfieldSet(hPtr[0],h263->src,21,3);
  273.     hPtr[0]=bitfieldSet(hPtr[0],h263->i,15,1);
  274.     hPtr[0]=bitfieldSet(hPtr[0],h263->a,14,1);
  275.     hPtr[0]=bitfieldSet(hPtr[0],h263->s,13,1);
  276.     p->payload=H263;
  277.     liConvertHeader2l((BYTE*)hPtr,0,dwords);
  278.     return 0;
  279. }
  280. INT32 RVCALLCONV rtpH263Unpack(
  281.                                 OUT     void*buf,
  282.                                 IN  INT32 len,
  283.                                 OUT     rtpParam*p,
  284.                                 OUT void*param)
  285. {
  286.     H263param*h263=(H263param*)param;
  287.     UINT32*hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  288.     if(len);
  289.     p->sByte+=4;
  290.     liConvertHeader2h((BYTE*)hPtr,0,1);
  291.     h263->f=bitfieldGet(hPtr[0],31,1);
  292.     h263->p=bitfieldGet(hPtr[0],30,1);
  293.     h263->sBit=bitfieldGet(hPtr[0],27,3);
  294.     h263->eBit=bitfieldGet(hPtr[0],24,3);
  295.     h263->src=bitfieldGet(hPtr[0],21,3);
  296.     h263->i=bitfieldGet(hPtr[0],15,1);
  297.     h263->a=bitfieldGet(hPtr[0],14,1);
  298.     h263->s=bitfieldGet(hPtr[0],13,1);
  299.     if (h263->f)
  300.     {
  301.         int aDwords=h263->p+1;
  302.         liConvertHeader2h((BYTE*)hPtr,1,aDwords);
  303.         p->sByte+=4*aDwords;
  304.         h263->mbaP=bitfieldGet(hPtr[0],0,8);
  305.         h263->gobN=bitfieldGet(hPtr[0],8,5);
  306.         h263->quant=bitfieldGet(hPtr[0],16,5);
  307.         h263->vMv2=bitfieldGet(hPtr[1],0,8);
  308.         h263->hMv2=bitfieldGet(hPtr[1],8,8);
  309.         h263->vMv1=bitfieldGet(hPtr[1],16,8);
  310.         h263->hMv1=bitfieldGet(hPtr[1],24,8);
  311.         hPtr=(UINT32*)((BYTE*)buf+p->sByte-4);
  312.     }
  313.     if (h263->p)
  314.     {
  315.         h263->dbq=bitfieldGet(hPtr[0],11,2);
  316.         h263->trb=bitfieldGet(hPtr[0],8,3);
  317.         h263->tr=bitfieldGet(hPtr[0],0,8);
  318.     }
  319.     return 0;
  320. }
  321. INT32 RVCALLCONV rtpH263GetHeaderLength()
  322. {
  323.     return rtpGetHeaderLength()+12;
  324. }
  325. INT32 RVCALLCONV rtpH263aPack(
  326.                               IN    void*buf,
  327.                               IN    INT32 len,
  328.                               IN    rtpParam*p,
  329.                               IN    void*param)
  330. {
  331.     H263aparam*h263a=(H263aparam*)param;
  332.     UINT32*hPtr=NULL;
  333.     int dwords=0;
  334.     if(len);
  335.     if (h263a->p)
  336.     {
  337.         dwords=1;
  338.         p->sByte-=4;
  339.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  340.         hPtr[0]=bitfieldSet(0,h263a->dbq,11,2);
  341.         hPtr[0]=bitfieldSet(hPtr[0],h263a->trb,8,3);
  342.         hPtr[0]=bitfieldSet(hPtr[0],h263a->tr,0,8);
  343.     }
  344.     if (h263a->f)
  345.     {
  346.         dwords+=2;
  347.         p->sByte-=8;
  348.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  349.         hPtr[0]=bitfieldSet(0,h263a->mbaP,2,9);
  350.         hPtr[0]=bitfieldSet(hPtr[0],h263a->gobN,11,5);
  351.         hPtr[0]=bitfieldSet(hPtr[0],h263a->quant,16,5);
  352.         hPtr[1]=bitfieldSet(      0,h263a->vMv2, 0,7);
  353.         hPtr[1]=bitfieldSet(hPtr[1],h263a->hMv2, 7,7);
  354.         hPtr[1]=bitfieldSet(hPtr[1],h263a->vMv1,14,7);
  355.         hPtr[1]=bitfieldSet(hPtr[1],h263a->hMv1,21,7);
  356.     hPtr[1]=bitfieldSet(hPtr[1],h263a->a,28,1);
  357.         hPtr[1]=bitfieldSet(hPtr[1],h263a->s,29,1);
  358.         hPtr[1]=bitfieldSet(hPtr[1],h263a->u,30,1);
  359.         hPtr[1]=bitfieldSet(hPtr[1],h263a->i,31,1);
  360.     }
  361.     if (!h263a->f && !h263a->p)
  362.     {
  363.         dwords=1;
  364.         p->sByte-=4;
  365.         hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  366.         hPtr[0]=bitfieldSet(      0,h263a->a,17,1);
  367.         hPtr[0]=bitfieldSet(hPtr[0],h263a->s,18,1);
  368.         hPtr[0]=bitfieldSet(hPtr[0],h263a->u,19,1);
  369.         hPtr[0]=bitfieldSet(hPtr[0],h263a->i,20,1); ;
  370.     }
  371.     hPtr[0]=bitfieldSet(hPtr[0],h263a->f,31,1);
  372.     hPtr[0]=bitfieldSet(hPtr[0],h263a->p,30,1);
  373.     hPtr[0]=bitfieldSet(hPtr[0],h263a->sBit,27,3);
  374.     hPtr[0]=bitfieldSet(hPtr[0],h263a->eBit,24,3);
  375.     hPtr[0]=bitfieldSet(hPtr[0],h263a->src,21,3);
  376.     p->payload=H263;
  377.     liConvertHeader2l((BYTE*)hPtr,0,dwords);
  378.     return 0;
  379. }
  380. INT32 RVCALLCONV rtpH263aUnpack(
  381.                                 OUT     void*buf,
  382.                                 IN  INT32 len,
  383.                                 OUT     rtpParam*p,
  384.                                 OUT void*param)
  385. {
  386.     H263aparam*h263a=(H263aparam*)param;
  387.     UINT32*hPtr=(UINT32*)((BYTE*)buf+p->sByte);
  388.     if(len);
  389.     p->sByte+=4;
  390.     liConvertHeader2h((BYTE*)hPtr,0,1);
  391.     h263a->f=bitfieldGet(hPtr[0],31,1);
  392.     h263a->p=bitfieldGet(hPtr[0],30,1);
  393.     h263a->sBit=bitfieldGet(hPtr[0],27,3);
  394.     h263a->eBit=bitfieldGet(hPtr[0],24,3);
  395.     h263a->src=bitfieldGet(hPtr[0],21,3);
  396.     if (h263a->f)
  397.     {
  398.         int aDwords=h263a->p+1;
  399.         liConvertHeader2h((BYTE*)hPtr,1,aDwords);
  400.         p->sByte+=4*aDwords;
  401.         h263a->mbaP=bitfieldGet(hPtr[0],2,9);
  402.         h263a->gobN=bitfieldGet(hPtr[0],11,5);
  403.         h263a->quant=bitfieldGet(hPtr[0],16,5);
  404.         h263a->vMv2=bitfieldGet(hPtr[1],0,7);
  405.         h263a->hMv2=bitfieldGet(hPtr[1],7,7);
  406.         h263a->vMv1=bitfieldGet(hPtr[1],14,7);
  407.         h263a->hMv1=bitfieldGet(hPtr[1],21,7);
  408.     h263a->i=bitfieldGet(hPtr[1],31,1);
  409.     h263a->u=bitfieldGet(hPtr[1],30,1);
  410.     h263a->s=bitfieldGet(hPtr[1],29,1);
  411.     h263a->a=bitfieldGet(hPtr[1],28,1);
  412.         hPtr=(UINT32*)((BYTE*)buf+p->sByte-4);
  413.     }
  414.     if (h263a->p)
  415.     {
  416.         h263a->dbq=bitfieldGet(hPtr[0],11,2);
  417.         h263a->trb=bitfieldGet(hPtr[0],8,3);
  418.         h263a->tr=bitfieldGet(hPtr[0],0,8);
  419.     }
  420.     if (!h263a->f && !h263a->p)
  421.     {
  422.       h263a->i=bitfieldGet(hPtr[0],20,1);
  423.       h263a->u=bitfieldGet(hPtr[0],19,1);
  424.       h263a->s=bitfieldGet(hPtr[0],18,1);
  425.       h263a->a=bitfieldGet(hPtr[0],17,1);
  426.     }
  427.     return 0;
  428. }
  429. INT32 RVCALLCONV rtpH263aGetHeaderLength()
  430. {
  431.     return rtpGetHeaderLength()+12;
  432. }
  433. #ifdef __cplusplus
  434. }
  435. #endif