ARTPSource.h revision cf7b9c7aae758ac0b99833915053c63c2ac46e09
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_SOURCE_H_
18
19#define A_RTP_SOURCE_H_
20
21#include <stdint.h>
22
23#include <media/stagefright/foundation/ABase.h>
24#include <utils/List.h>
25#include <utils/RefBase.h>
26
27namespace android {
28
29struct ABuffer;
30struct AMessage;
31struct ARTPAssembler;
32struct ASessionDescription;
33
34struct ARTPSource : public RefBase {
35    ARTPSource(
36            uint32_t id,
37            const sp<ASessionDescription> &sessionDesc, size_t index,
38            const sp<AMessage> &notify);
39
40    void processRTPPacket(const sp<ABuffer> &buffer);
41    void timeUpdate(uint32_t rtpTime, uint64_t ntpTime);
42
43    List<sp<ABuffer> > *queue() { return &mQueue; }
44
45private:
46    uint32_t mID;
47    uint32_t mHighestSeqNumber;
48    int32_t mNumBuffersReceived;
49
50    List<sp<ABuffer> > mQueue;
51    sp<ARTPAssembler> mAssembler;
52
53    size_t mNumTimes;
54    uint64_t mNTPTime[2];
55    uint32_t mRTPTime[2];
56
57    uint64_t RTP2NTP(uint32_t rtpTime) const;
58
59    bool queuePacket(const sp<ABuffer> &buffer);
60    void dump() const;
61
62    DISALLOW_EVIL_CONSTRUCTORS(ARTPSource);
63};
64
65}  // namespace android
66
67#endif  // A_RTP_SOURCE_H_
68