2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef A_RTP_CONNECTION_H_
19 #define A_RTP_CONNECTION_H_
21 #include <media/stagefright/foundation/AHandler.h>
22 #include <utils/List.h>
28 struct ASessionDescription;
30 struct ARTPConnection : public AHandler {
33 kRegularlyRequestFIR = 2,
36 ARTPConnection(uint32_t flags = 0);
39 int rtpSocket, int rtcpSocket,
40 const sp<ASessionDescription> &sessionDesc, size_t index,
41 const sp<AMessage> ¬ify,
44 void removeStream(int rtpSocket, int rtcpSocket);
46 void injectPacket(int index, const sp<ABuffer> &buffer);
48 // Creates a pair of UDP datagram sockets bound to adjacent ports
49 // (the rtpSocket is bound to an even port, the rtcpSocket to the
51 static void MakePortPair(
52 int *rtpSocket, int *rtcpSocket, unsigned *rtpPort);
54 void fakeTimestamps();
57 virtual ~ARTPConnection();
58 virtual void onMessageReceived(const sp<AMessage> &msg);
69 static const int64_t kSelectTimeoutUs;
74 List<StreamInfo> mStreams;
76 bool mPollEventPending;
77 int64_t mLastReceiverReportTimeUs;
79 void onAddStream(const sp<AMessage> &msg);
80 void onRemoveStream(const sp<AMessage> &msg);
82 void onInjectPacket(const sp<AMessage> &msg);
83 void onSendReceiverReports();
84 void onFakeTimestamps();
86 status_t receive(StreamInfo *info, bool receiveRTP);
88 status_t parseRTP(StreamInfo *info, const sp<ABuffer> &buffer);
89 status_t parseRTCP(StreamInfo *info, const sp<ABuffer> &buffer);
90 status_t parseSR(StreamInfo *info, const uint8_t *data, size_t size);
91 status_t parseBYE(StreamInfo *info, const uint8_t *data, size_t size);
93 sp<ARTPSource> findSource(StreamInfo *info, uint32_t id);
97 DISALLOW_EVIL_CONSTRUCTORS(ARTPConnection);
100 } // namespace android
102 #endif // A_RTP_CONNECTION_H_