Andreas Huber | 8a61c22 | 2012-08-31 14:05:27 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace android { |
| 25 | |
| 26 | struct ABuffer; |
| 27 | struct SurfaceComposerClient; |
| 28 | struct SurfaceControl; |
| 29 | struct Surface; |
| 30 | struct IMediaPlayer; |
| 31 | struct 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. |
| 36 | struct TunnelRenderer : public AHandler { |
| 37 | TunnelRenderer( |
| 38 | const sp<AMessage> ¬ifyLost, |
Andy McFadden | 484566c | 2012-12-18 09:46:54 -0800 | [diff] [blame^] | 39 | const sp<IGraphicBufferProducer> &bufferProducer); |
Andreas Huber | 8a61c22 | 2012-08-31 14:05:27 -0700 | [diff] [blame] | 40 | |
| 41 | sp<ABuffer> dequeueBuffer(); |
| 42 | |
| 43 | enum { |
| 44 | kWhatQueueBuffer, |
| 45 | }; |
| 46 | |
| 47 | protected: |
| 48 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 49 | virtual ~TunnelRenderer(); |
| 50 | |
| 51 | private: |
| 52 | struct PlayerClient; |
| 53 | struct StreamSource; |
| 54 | |
| 55 | mutable Mutex mLock; |
| 56 | |
| 57 | sp<AMessage> mNotifyLost; |
Andy McFadden | 484566c | 2012-12-18 09:46:54 -0800 | [diff] [blame^] | 58 | sp<IGraphicBufferProducer> mSurfaceTex; |
Andreas Huber | 8a61c22 | 2012-08-31 14:05:27 -0700 | [diff] [blame] | 59 | |
| 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_ |