blob: 52e6e66f1292843f65fafc3d93ebbca6479f8369 [file] [log] [blame]
Andreas Huber8a61c222012-08-31 14:05:27 -07001/*
2 * Copyright 2012, 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 TUNNEL_RENDERER_H_
18
19#define TUNNEL_RENDERER_H_
20
21#include <gui/Surface.h>
22#include <media/stagefright/foundation/AHandler.h>
23
24namespace android {
25
26struct ABuffer;
27struct SurfaceComposerClient;
28struct SurfaceControl;
29struct Surface;
30struct IMediaPlayer;
31struct IStreamListener;
32
33// This class reassembles incoming RTP packets into the correct order
34// and sends the resulting transport stream to a mediaplayer instance
35// for playback.
36struct TunnelRenderer : public AHandler {
37 TunnelRenderer(
38 const sp<AMessage> &notifyLost,
Andy McFadden484566c2012-12-18 09:46:54 -080039 const sp<IGraphicBufferProducer> &bufferProducer);
Andreas Huber8a61c222012-08-31 14:05:27 -070040
41 sp<ABuffer> dequeueBuffer();
42
43 enum {
44 kWhatQueueBuffer,
45 };
46
47protected:
48 virtual void onMessageReceived(const sp<AMessage> &msg);
49 virtual ~TunnelRenderer();
50
51private:
52 struct PlayerClient;
53 struct StreamSource;
54
55 mutable Mutex mLock;
56
57 sp<AMessage> mNotifyLost;
Andy McFadden484566c2012-12-18 09:46:54 -080058 sp<IGraphicBufferProducer> mSurfaceTex;
Andreas Huber8a61c222012-08-31 14:05:27 -070059
60 List<sp<ABuffer> > mPackets;
61 int64_t mTotalBytesQueued;
62
63 sp<SurfaceComposerClient> mComposerClient;
64 sp<SurfaceControl> mSurfaceControl;
65 sp<Surface> mSurface;
66 sp<PlayerClient> mPlayerClient;
67 sp<IMediaPlayer> mPlayer;
68 sp<StreamSource> mStreamSource;
69
70 int32_t mLastDequeuedExtSeqNo;
71 int64_t mFirstFailedAttemptUs;
72 bool mRequestedRetransmission;
73
74 void initPlayer();
75 void destroyPlayer();
76
77 void queueBuffer(const sp<ABuffer> &buffer);
78
79 DISALLOW_EVIL_CONSTRUCTORS(TunnelRenderer);
80};
81
82} // namespace android
83
84#endif // TUNNEL_RENDERER_H_