• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 
19 #ifndef RTSP_EMBEDDED_RTP_H_
20 #define RTSP_EMBEDDED_RTP_H_
21 
22 //#include "oscl_types.h"
23 #include "oscl_base.h"
24 #include "rtp_packet.h"
25 
26 #ifdef RTSP_EMB_RTP_DOLLAR_SEQUENCE_BUFFER_SIZE
27 #error Hey, somebody is using RTSP_EMB_RTP_DOLLAR_SEQUENCE_BUFFER_SIZE
28 #else
29 #define RTSP_EMB_RTP_DOLLAR_SEQUENCE_BUFFER_SIZE 4
30 #endif
31 
32 #ifdef RTSP_EMB_RTP_MAX_NUM_BUFFER_FRAGMENTS
33 #error Hey, somebody is using RTSP_EMB_RTP_MAX_NUM_BUFFER_FRAGMENTS
34 #else
35 #define RTSP_EMB_RTP_MAX_NUM_BUFFER_FRAGMENTS 32
36 #endif
37 
38 class RtspEmbeddedRtpPacket
39 {
40     public:
41 
42         typedef enum
43         {
44             BOUND,
45             UNBOUND,
46             SEEK_ERROR,
47             NOT_ENOUGH_BUFFER_FRAGS,
48             INVALID_RTP_PACKET
49         } Status;
50 
51     protected:
52 
53         Status  status;
54 
55     public:
56 
57         inline Status
getStatus()58         getStatus()
59         {
60             return  status;
61         }
62 
63         inline bool
isOk()64         isOk()
65         {
66             return ((UNBOUND == status) || (BOUND == status));
67         }
68 
69     public:
70 
71         typedef uint8   ChannelIdType;
72         typedef uint16  LengthType;
73 
74     private:
75 
76         RtspEmbeddedRtpPacket(const RtspEmbeddedRtpPacket &);
77         RtspEmbeddedRtpPacket & operator= (const RtspEmbeddedRtpPacket &);
78 
79     protected:
80 
81 //    RTPPacket *       rtpPacket;
82 //    ChannelIdType     channelId;
83 //    LengthType        length;
84 
85         uint8             dollarSequenceBuffer[RTSP_EMB_RTP_DOLLAR_SEQUENCE_BUFFER_SIZE];
86         BufferFragment    fragments[ RTSP_EMB_RTP_MAX_NUM_BUFFER_FRAGMENTS ];
87 
88 //    LengthType        sizeRemaining;
89         int               currentBufferFragIdx;
90         int               totalNumFragments;
91 
92         bool              boundaryReached;
93 
94     public:
95 
RtspEmbeddedRtpPacket()96         RtspEmbeddedRtpPacket()
97                 : status(UNBOUND)
98         {}
99 
100     protected:
101 
102         inline bool checkSanity(RTPPacket *     newRtpPacket,
103                                 ChannelIdType   newChannelId,
104                                 LengthType      newLength
105                                );
106         inline void buildDollarSequenceBuffer(ChannelIdType   newChannelId,
107                                               LengthType      newLength
108                                              );
109         inline void fillOutBufferFragmentGroupFromPacket(RTPPacket * newRtpPacket);
110         inline void startAccounting();
111 
112     public:
113 
114         bool        bind(RTPPacket *     newRtpPacket,
115                          ChannelIdType   newChannelId,
116                          LengthType      newLength
117                         );
118 
119         void        unbind();
120 
121         bool        getRemainingFrags(BufferFragment * &,
122                                       uint32 &
123                                      );
124 
125         bool        registerBytesWritten(uint32 bytesWritten);
126 };
127 
128 #endif  // RTSP_EMBEDDED_RTP_H_
129