netwerk/protocol/rtsp/rtsp/RTSPSource.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /*
michael@0 2 * Copyright (C) 2010 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 #ifndef RTSP_SOURCE_H_
michael@0 18
michael@0 19 #define RTSP_SOURCE_H_
michael@0 20
michael@0 21 #include <utils/RefBase.h>
michael@0 22 #include <media/stagefright/foundation/AString.h>
michael@0 23 #include <media/stagefright/foundation/AHandlerReflector.h>
michael@0 24
michael@0 25 #include "nsCOMPtr.h"
michael@0 26 #include "nsString.h"
michael@0 27 #include "nsIStreamingProtocolController.h"
michael@0 28 #include "nsProxyRelease.h"
michael@0 29
michael@0 30 namespace android {
michael@0 31
michael@0 32 struct MetaData;
michael@0 33 struct ABuffer;
michael@0 34 struct ALooper;
michael@0 35 struct AnotherPacketSource;
michael@0 36 struct RtspConnectionHandler;
michael@0 37
michael@0 38 class RTSPSource : public RefBase
michael@0 39 {
michael@0 40 public:
michael@0 41
michael@0 42 RTSPSource(
michael@0 43 nsIStreamingProtocolListener *aListener,
michael@0 44 const char *url,
michael@0 45 bool uidValid = false,
michael@0 46 uid_t uid = 0);
michael@0 47
michael@0 48 void start();
michael@0 49 void stop();
michael@0 50
michael@0 51 void play();
michael@0 52 void pause();
michael@0 53 void seek(uint64_t timeUs);
michael@0 54 void resume();
michael@0 55 void suspend();
michael@0 56
michael@0 57 status_t feedMoreTSData();
michael@0 58
michael@0 59 sp<MetaData> getFormat(bool audio);
michael@0 60 status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
michael@0 61
michael@0 62 status_t getDuration(int64_t *durationUs);
michael@0 63 status_t seekTo(int64_t seekTimeUs);
michael@0 64 bool isSeekable();
michael@0 65
michael@0 66 void onMessageReceived(const sp<AMessage> &msg);
michael@0 67
michael@0 68 protected:
michael@0 69 ~RTSPSource();
michael@0 70
michael@0 71 private:
michael@0 72 enum {
michael@0 73 kWhatNotify = 'noti',
michael@0 74 kWhatDisconnect = 'disc',
michael@0 75 kWhatPerformSeek = 'seek',
michael@0 76 kWhatPerformPlay = 'play',
michael@0 77 kWhatPerformPause = 'paus',
michael@0 78 kWhatPerformResume = 'resu',
michael@0 79 kWhatPerformSuspend = 'susp',
michael@0 80 };
michael@0 81
michael@0 82 enum State {
michael@0 83 DISCONNECTED,
michael@0 84 CONNECTING,
michael@0 85 CONNECTED,
michael@0 86 SEEKING,
michael@0 87 PAUSING,
michael@0 88 PLAYING,
michael@0 89 };
michael@0 90
michael@0 91 enum Flags {
michael@0 92 // Don't log any URLs.
michael@0 93 kFlagIncognito = 1,
michael@0 94 };
michael@0 95
michael@0 96 struct TrackInfo {
michael@0 97 sp<AnotherPacketSource> mSource;
michael@0 98
michael@0 99 int32_t mTimeScale;
michael@0 100 uint32_t mRTPTime;
michael@0 101 int64_t mNormalPlaytimeUs;
michael@0 102 bool mNPTMappingValid;
michael@0 103 bool mIsAudio;
michael@0 104 uint64_t mLatestReceivedUnit;
michael@0 105 uint64_t mLatestPausedUnit;
michael@0 106 };
michael@0 107
michael@0 108 AString mURL;
michael@0 109 bool mUIDValid;
michael@0 110 uid_t mUID;
michael@0 111 State mState;
michael@0 112 status_t mFinalResult;
michael@0 113 uint32_t mDisconnectReplyID;
michael@0 114 uint64_t mLatestPausedUnit;
michael@0 115
michael@0 116 sp<ALooper> mLooper;
michael@0 117 sp<AHandlerReflector<RTSPSource> > mReflector;
michael@0 118 sp<RtspConnectionHandler> mHandler;
michael@0 119
michael@0 120 Vector<TrackInfo> mTracks;
michael@0 121 sp<AnotherPacketSource> mAudioTrack;
michael@0 122 sp<AnotherPacketSource> mVideoTrack;
michael@0 123
michael@0 124 int32_t mSeekGeneration;
michael@0 125
michael@0 126 sp<AnotherPacketSource> getSource(bool audio);
michael@0 127
michael@0 128 void onConnected(bool isSeekable);
michael@0 129 void onDisconnected(const sp<AMessage> &msg);
michael@0 130 void finishDisconnectIfPossible();
michael@0 131
michael@0 132 void performSeek(int64_t seekTimeUs);
michael@0 133
michael@0 134 void performPlay(int64_t playTimeUs);
michael@0 135
michael@0 136 void performPause();
michael@0 137
michael@0 138 void performResume();
michael@0 139
michael@0 140 void performSuspend();
michael@0 141
michael@0 142 void onTrackDataAvailable(size_t trackIndex);
michael@0 143
michael@0 144 nsMainThreadPtrHandle<nsIStreamingProtocolListener> mListener;
michael@0 145 int mPrintCount;
michael@0 146
michael@0 147 DISALLOW_EVIL_CONSTRUCTORS(RTSPSource);
michael@0 148 };
michael@0 149
michael@0 150 } // namespace android
michael@0 151
michael@0 152 #endif // RTSP_SOURCE_H_

mercurial