Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 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 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "HTTPLiveSource" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include "HTTPLiveSource.h" |
| 22 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 23 | #include "AnotherPacketSource.h" |
| 24 | #include "LiveDataSource.h" |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 25 | |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 26 | #include <media/IMediaHTTPService.h> |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 27 | #include <media/stagefright/foundation/ABuffer.h> |
| 28 | #include <media/stagefright/foundation/ADebug.h> |
| 29 | #include <media/stagefright/foundation/AMessage.h> |
| 30 | #include <media/stagefright/MediaErrors.h> |
| 31 | #include <media/stagefright/MetaData.h> |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 32 | #include <media/stagefright/MediaDefs.h> |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 33 | |
| 34 | namespace android { |
| 35 | |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 36 | NuPlayer::HTTPLiveSource::HTTPLiveSource( |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 37 | const sp<AMessage> ¬ify, |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 38 | const sp<IMediaHTTPService> &httpService, |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 39 | const char *url, |
Andreas Huber | 81e6844 | 2014-02-05 11:52:33 -0800 | [diff] [blame] | 40 | const KeyedVector<String8, String8> *headers) |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 41 | : Source(notify), |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 42 | mHTTPService(httpService), |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 43 | mURL(url), |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 44 | mFlags(0), |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 45 | mFinalResult(OK), |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 46 | mOffset(0), |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 47 | mFetchSubtitleDataGeneration(0), |
| 48 | mFetchMetaDataGeneration(0), |
| 49 | mHasMetadata(false), |
| 50 | mMetadataSelected(false) { |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 51 | if (headers) { |
| 52 | mExtraHeaders = *headers; |
| 53 | |
| 54 | ssize_t index = |
| 55 | mExtraHeaders.indexOfKey(String8("x-hide-urls-from-log")); |
| 56 | |
| 57 | if (index >= 0) { |
| 58 | mFlags |= kFlagIncognito; |
| 59 | |
| 60 | mExtraHeaders.removeItemsAt(index); |
| 61 | } |
| 62 | } |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | NuPlayer::HTTPLiveSource::~HTTPLiveSource() { |
Andreas Huber | 2048d0c | 2011-07-15 16:25:41 -0700 | [diff] [blame] | 66 | if (mLiveSession != NULL) { |
| 67 | mLiveSession->disconnect(); |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 68 | |
Chong Zhang | 1228d6b | 2014-08-12 21:25:48 -0700 | [diff] [blame] | 69 | mLiveLooper->unregisterHandler(mLiveSession->id()); |
| 70 | mLiveLooper->unregisterHandler(id()); |
Andreas Huber | 2048d0c | 2011-07-15 16:25:41 -0700 | [diff] [blame] | 71 | mLiveLooper->stop(); |
Chong Zhang | 1228d6b | 2014-08-12 21:25:48 -0700 | [diff] [blame] | 72 | |
| 73 | mLiveSession.clear(); |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 74 | mLiveLooper.clear(); |
Andreas Huber | 2048d0c | 2011-07-15 16:25:41 -0700 | [diff] [blame] | 75 | } |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 76 | } |
| 77 | |
Andreas Huber | 9575c96 | 2013-02-05 13:59:56 -0800 | [diff] [blame] | 78 | void NuPlayer::HTTPLiveSource::prepareAsync() { |
Chong Zhang | 1228d6b | 2014-08-12 21:25:48 -0700 | [diff] [blame] | 79 | if (mLiveLooper == NULL) { |
| 80 | mLiveLooper = new ALooper; |
| 81 | mLiveLooper->setName("http live"); |
| 82 | mLiveLooper->start(); |
| 83 | |
| 84 | mLiveLooper->registerHandler(this); |
| 85 | } |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 86 | |
Lajos Molnar | 1d15ab5 | 2015-03-04 16:46:34 -0800 | [diff] [blame] | 87 | sp<AMessage> notify = new AMessage(kWhatSessionNotify, this); |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 88 | |
Andreas Huber | 7314fa1 | 2011-02-24 14:42:48 -0800 | [diff] [blame] | 89 | mLiveSession = new LiveSession( |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 90 | notify, |
Andreas Huber | 9b80c2b | 2011-06-30 15:47:02 -0700 | [diff] [blame] | 91 | (mFlags & kFlagIncognito) ? LiveSession::kFlagIncognito : 0, |
Andreas Huber | 81e6844 | 2014-02-05 11:52:33 -0800 | [diff] [blame] | 92 | mHTTPService); |
Andreas Huber | 7314fa1 | 2011-02-24 14:42:48 -0800 | [diff] [blame] | 93 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 94 | mLiveLooper->registerHandler(mLiveSession); |
| 95 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 96 | mLiveSession->connectAsync( |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 97 | mURL.c_str(), mExtraHeaders.isEmpty() ? NULL : &mExtraHeaders); |
Andreas Huber | 9575c96 | 2013-02-05 13:59:56 -0800 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void NuPlayer::HTTPLiveSource::start() { |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 103 | sp<AMessage> NuPlayer::HTTPLiveSource::getFormat(bool audio) { |
Robert Shih | 7350b05 | 2015-10-01 15:50:14 -0700 | [diff] [blame^] | 104 | sp<AMessage> format; |
| 105 | status_t err = -EWOULDBLOCK; |
| 106 | if (mLiveSession != NULL) { |
| 107 | err = mLiveSession->getStreamFormat( |
| 108 | audio ? LiveSession::STREAMTYPE_AUDIO |
| 109 | : LiveSession::STREAMTYPE_VIDEO, |
| 110 | &format); |
Robert Shih | 1098d87 | 2014-11-06 13:58:48 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Robert Shih | 7350b05 | 2015-10-01 15:50:14 -0700 | [diff] [blame^] | 113 | if (err == -EWOULDBLOCK) { |
| 114 | format = new AMessage(); |
| 115 | format->setInt32("err", err); |
| 116 | return format; |
| 117 | } |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 118 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 119 | if (err != OK) { |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 120 | return NULL; |
| 121 | } |
| 122 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 123 | return format; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 124 | } |
| 125 | |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 126 | status_t NuPlayer::HTTPLiveSource::feedMoreTSData() { |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 127 | return OK; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | status_t NuPlayer::HTTPLiveSource::dequeueAccessUnit( |
| 131 | bool audio, sp<ABuffer> *accessUnit) { |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 132 | return mLiveSession->dequeueAccessUnit( |
| 133 | audio ? LiveSession::STREAMTYPE_AUDIO |
| 134 | : LiveSession::STREAMTYPE_VIDEO, |
| 135 | accessUnit); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 138 | status_t NuPlayer::HTTPLiveSource::getDuration(int64_t *durationUs) { |
| 139 | return mLiveSession->getDuration(durationUs); |
| 140 | } |
| 141 | |
Chong Zhang | 404fced | 2014-06-11 14:45:31 -0700 | [diff] [blame] | 142 | size_t NuPlayer::HTTPLiveSource::getTrackCount() const { |
| 143 | return mLiveSession->getTrackCount(); |
| 144 | } |
| 145 | |
| 146 | sp<AMessage> NuPlayer::HTTPLiveSource::getTrackInfo(size_t trackIndex) const { |
| 147 | return mLiveSession->getTrackInfo(trackIndex); |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Robert Shih | 89bf252 | 2014-07-29 19:25:10 -0700 | [diff] [blame] | 150 | ssize_t NuPlayer::HTTPLiveSource::getSelectedTrack(media_track_type type) const { |
| 151 | if (mLiveSession == NULL) { |
| 152 | return -1; |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 153 | } else if (type == MEDIA_TRACK_TYPE_METADATA) { |
| 154 | // MEDIA_TRACK_TYPE_METADATA is always last track |
| 155 | // mMetadataSelected can only be true when mHasMetadata is true |
| 156 | return mMetadataSelected ? (mLiveSession->getTrackCount() - 1) : -1; |
Robert Shih | 89bf252 | 2014-07-29 19:25:10 -0700 | [diff] [blame] | 157 | } else { |
| 158 | return mLiveSession->getSelectedTrack(type); |
| 159 | } |
| 160 | } |
| 161 | |
Robert Shih | 6ffb1fd | 2014-10-29 16:24:32 -0700 | [diff] [blame] | 162 | status_t NuPlayer::HTTPLiveSource::selectTrack(size_t trackIndex, bool select, int64_t /*timeUs*/) { |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 163 | if (mLiveSession == NULL) { |
| 164 | return INVALID_OPERATION; |
| 165 | } |
| 166 | |
| 167 | status_t err = INVALID_OPERATION; |
| 168 | bool postFetchMsg = false, isSub = false; |
Robert Shih | 055404e | 2015-05-15 10:12:21 -0700 | [diff] [blame] | 169 | if (!mHasMetadata || trackIndex != mLiveSession->getTrackCount() - 1) { |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 170 | err = mLiveSession->selectTrack(trackIndex, select); |
| 171 | postFetchMsg = select; |
| 172 | isSub = true; |
| 173 | } else { |
Robert Shih | 055404e | 2015-05-15 10:12:21 -0700 | [diff] [blame] | 174 | // metadata track; i.e. (mHasMetadata && trackIndex == mLiveSession->getTrackCount() - 1) |
| 175 | if (mMetadataSelected && !select) { |
| 176 | err = OK; |
| 177 | } else if (!mMetadataSelected && select) { |
| 178 | postFetchMsg = true; |
| 179 | err = OK; |
| 180 | } else { |
| 181 | err = BAD_VALUE; // behave as LiveSession::selectTrack |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 182 | } |
Robert Shih | 055404e | 2015-05-15 10:12:21 -0700 | [diff] [blame] | 183 | |
| 184 | mMetadataSelected = select; |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 185 | } |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 186 | |
| 187 | if (err == OK) { |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 188 | int32_t &generation = isSub ? mFetchSubtitleDataGeneration : mFetchMetaDataGeneration; |
| 189 | generation++; |
| 190 | if (postFetchMsg) { |
| 191 | int32_t what = isSub ? kWhatFetchSubtitleData : kWhatFetchMetaData; |
| 192 | sp<AMessage> msg = new AMessage(what, this); |
| 193 | msg->setInt32("generation", generation); |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 194 | msg->post(); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // LiveSession::selectTrack returns BAD_VALUE when selecting the currently |
| 199 | // selected track, or unselecting a non-selected track. In this case it's an |
| 200 | // no-op so we return OK. |
Andreas Huber | 84333e0 | 2014-02-07 15:36:10 -0800 | [diff] [blame] | 201 | return (err == OK || err == BAD_VALUE) ? (status_t)OK : err; |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 204 | status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) { |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 205 | return mLiveSession->seekTo(seekTimeUs); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 206 | } |
| 207 | |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 208 | void NuPlayer::HTTPLiveSource::pollForRawData( |
| 209 | const sp<AMessage> &msg, int32_t currentGeneration, |
| 210 | LiveSession::StreamType fetchType, int32_t pushWhat) { |
| 211 | |
| 212 | int32_t generation; |
| 213 | CHECK(msg->findInt32("generation", &generation)); |
| 214 | |
| 215 | if (generation != currentGeneration) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | sp<ABuffer> buffer; |
| 220 | while (mLiveSession->dequeueAccessUnit(fetchType, &buffer) == OK) { |
| 221 | |
| 222 | sp<AMessage> notify = dupNotify(); |
| 223 | notify->setInt32("what", pushWhat); |
| 224 | notify->setBuffer("buffer", buffer); |
| 225 | |
| 226 | int64_t timeUs, baseUs, delayUs; |
| 227 | CHECK(buffer->meta()->findInt64("baseUs", &baseUs)); |
| 228 | CHECK(buffer->meta()->findInt64("timeUs", &timeUs)); |
| 229 | delayUs = baseUs + timeUs - ALooper::GetNowUs(); |
| 230 | |
| 231 | if (fetchType == LiveSession::STREAMTYPE_SUBTITLES) { |
| 232 | notify->post(); |
| 233 | msg->post(delayUs > 0ll ? delayUs : 0ll); |
| 234 | return; |
| 235 | } else if (fetchType == LiveSession::STREAMTYPE_METADATA) { |
| 236 | if (delayUs < -1000000ll) { // 1 second |
| 237 | continue; |
| 238 | } |
| 239 | notify->post(); |
| 240 | // push all currently available metadata buffers in each invocation of pollForRawData |
| 241 | // continue; |
| 242 | } else { |
| 243 | TRESPASS(); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | // try again in 1 second |
| 248 | msg->post(1000000ll); |
| 249 | } |
| 250 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 251 | void NuPlayer::HTTPLiveSource::onMessageReceived(const sp<AMessage> &msg) { |
| 252 | switch (msg->what()) { |
| 253 | case kWhatSessionNotify: |
| 254 | { |
| 255 | onSessionNotify(msg); |
| 256 | break; |
| 257 | } |
| 258 | |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 259 | case kWhatFetchSubtitleData: |
| 260 | { |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 261 | pollForRawData( |
| 262 | msg, mFetchSubtitleDataGeneration, |
| 263 | /* fetch */ LiveSession::STREAMTYPE_SUBTITLES, |
| 264 | /* push */ kWhatSubtitleData); |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 265 | |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 266 | break; |
| 267 | } |
| 268 | |
| 269 | case kWhatFetchMetaData: |
| 270 | { |
| 271 | if (!mMetadataSelected) { |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 272 | break; |
| 273 | } |
| 274 | |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 275 | pollForRawData( |
| 276 | msg, mFetchMetaDataGeneration, |
| 277 | /* fetch */ LiveSession::STREAMTYPE_METADATA, |
| 278 | /* push */ kWhatTimedMetaData); |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 279 | |
| 280 | break; |
| 281 | } |
| 282 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 283 | default: |
| 284 | Source::onMessageReceived(msg); |
| 285 | break; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | void NuPlayer::HTTPLiveSource::onSessionNotify(const sp<AMessage> &msg) { |
| 290 | int32_t what; |
| 291 | CHECK(msg->findInt32("what", &what)); |
| 292 | |
| 293 | switch (what) { |
| 294 | case LiveSession::kWhatPrepared: |
| 295 | { |
Marco Nelissen | 3e518fd | 2013-11-01 10:33:18 -0700 | [diff] [blame] | 296 | // notify the current size here if we have it, otherwise report an initial size of (0,0) |
| 297 | sp<AMessage> format = getFormat(false /* audio */); |
| 298 | int32_t width; |
| 299 | int32_t height; |
| 300 | if (format != NULL && |
| 301 | format->findInt32("width", &width) && format->findInt32("height", &height)) { |
Chong Zhang | ced1c2f | 2014-08-08 15:22:35 -0700 | [diff] [blame] | 302 | notifyVideoSizeChanged(format); |
Marco Nelissen | 3e518fd | 2013-11-01 10:33:18 -0700 | [diff] [blame] | 303 | } else { |
Chong Zhang | ced1c2f | 2014-08-08 15:22:35 -0700 | [diff] [blame] | 304 | notifyVideoSizeChanged(); |
Marco Nelissen | 3e518fd | 2013-11-01 10:33:18 -0700 | [diff] [blame] | 305 | } |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 306 | |
| 307 | uint32_t flags = FLAG_CAN_PAUSE; |
| 308 | if (mLiveSession->isSeekable()) { |
| 309 | flags |= FLAG_CAN_SEEK; |
| 310 | flags |= FLAG_CAN_SEEK_BACKWARD; |
| 311 | flags |= FLAG_CAN_SEEK_FORWARD; |
| 312 | } |
| 313 | |
| 314 | if (mLiveSession->hasDynamicDuration()) { |
| 315 | flags |= FLAG_DYNAMIC_DURATION; |
| 316 | } |
| 317 | |
| 318 | notifyFlagsChanged(flags); |
| 319 | |
| 320 | notifyPrepared(); |
| 321 | break; |
| 322 | } |
| 323 | |
| 324 | case LiveSession::kWhatPreparationFailed: |
| 325 | { |
| 326 | status_t err; |
| 327 | CHECK(msg->findInt32("err", &err)); |
| 328 | |
| 329 | notifyPrepared(err); |
| 330 | break; |
| 331 | } |
| 332 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 333 | case LiveSession::kWhatStreamsChanged: |
| 334 | { |
| 335 | uint32_t changedMask; |
| 336 | CHECK(msg->findInt32( |
| 337 | "changedMask", (int32_t *)&changedMask)); |
| 338 | |
| 339 | bool audio = changedMask & LiveSession::STREAMTYPE_AUDIO; |
| 340 | bool video = changedMask & LiveSession::STREAMTYPE_VIDEO; |
| 341 | |
| 342 | sp<AMessage> reply; |
| 343 | CHECK(msg->findMessage("reply", &reply)); |
| 344 | |
| 345 | sp<AMessage> notify = dupNotify(); |
| 346 | notify->setInt32("what", kWhatQueueDecoderShutdown); |
| 347 | notify->setInt32("audio", audio); |
| 348 | notify->setInt32("video", video); |
| 349 | notify->setMessage("reply", reply); |
| 350 | notify->post(); |
| 351 | break; |
| 352 | } |
| 353 | |
Chong Zhang | 7c87080 | 2015-03-17 16:27:56 -0700 | [diff] [blame] | 354 | case LiveSession::kWhatBufferingStart: |
| 355 | { |
| 356 | sp<AMessage> notify = dupNotify(); |
| 357 | notify->setInt32("what", kWhatPauseOnBufferingStart); |
| 358 | notify->post(); |
| 359 | break; |
| 360 | } |
| 361 | |
| 362 | case LiveSession::kWhatBufferingEnd: |
| 363 | { |
| 364 | sp<AMessage> notify = dupNotify(); |
| 365 | notify->setInt32("what", kWhatResumeOnBufferingEnd); |
| 366 | notify->post(); |
| 367 | break; |
| 368 | } |
| 369 | |
| 370 | |
| 371 | case LiveSession::kWhatBufferingUpdate: |
| 372 | { |
| 373 | sp<AMessage> notify = dupNotify(); |
| 374 | int32_t percentage; |
| 375 | CHECK(msg->findInt32("percentage", &percentage)); |
| 376 | notify->setInt32("what", kWhatBufferingUpdate); |
| 377 | notify->setInt32("percentage", percentage); |
| 378 | notify->post(); |
| 379 | break; |
| 380 | } |
| 381 | |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame] | 382 | case LiveSession::kWhatMetadataDetected: |
| 383 | { |
| 384 | if (!mHasMetadata) { |
| 385 | mHasMetadata = true; |
| 386 | |
| 387 | sp<AMessage> notify = dupNotify(); |
| 388 | // notification without buffer triggers MEDIA_INFO_METADATA_UPDATE |
| 389 | notify->setInt32("what", kWhatTimedMetaData); |
| 390 | notify->post(); |
| 391 | } |
| 392 | break; |
| 393 | } |
| 394 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 395 | case LiveSession::kWhatError: |
| 396 | { |
| 397 | break; |
| 398 | } |
| 399 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 400 | default: |
| 401 | TRESPASS(); |
| 402 | } |
| 403 | } |
| 404 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 405 | } // namespace android |
| 406 | |