1/*
2 * Copyright (C) 2010 The Android Open Source Project
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 express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A_RTP_SESSION_H_
18
19#define A_RTP_SESSION_H_
20
21#include <media/stagefright/foundation/AHandler.h>
22
23namespace android {
24
25struct APacketSource;
26struct ARTPConnection;
27struct ASessionDescription;
28struct MediaSource;
29
30struct ARTPSession : public AHandler {
31    ARTPSession();
32
33    status_t setup(const sp<ASessionDescription> &desc);
34
35    size_t countTracks();
36    sp<MediaSource> trackAt(size_t index);
37
38protected:
39    virtual void onMessageReceived(const sp<AMessage> &msg);
40
41    virtual ~ARTPSession();
42
43private:
44    enum {
45        kWhatAccessUnitComplete = 'accu'
46    };
47
48    struct TrackInfo {
49        int mRTPSocket;
50        int mRTCPSocket;
51
52        sp<APacketSource> mPacketSource;
53    };
54
55    status_t mInitCheck;
56    sp<ASessionDescription> mDesc;
57    sp<ARTPConnection> mRTPConn;
58
59    Vector<TrackInfo> mTracks;
60
61    bool validateMediaFormat(size_t index, unsigned *port) const;
62    static int MakeUDPSocket(unsigned port);
63
64    DISALLOW_EVIL_CONSTRUCTORS(ARTPSession);
65};
66
67}  // namespace android
68
69#endif  // A_RTP_SESSION_H_
70