NuPlayer.cpp revision 1cd139824b2e6832f239cd27d8962d3239053c02
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 "NuPlayer" 19#include <utils/Log.h> 20 21#include "NuPlayer.h" 22 23#include "HTTPLiveSource.h" 24#include "NuPlayerDecoder.h" 25#include "NuPlayerDriver.h" 26#include "NuPlayerRenderer.h" 27#include "NuPlayerSource.h" 28#include "RTSPSource.h" 29#include "StreamingSource.h" 30#include "GenericSource.h" 31 32#include "ATSParser.h" 33 34#include <media/stagefright/foundation/hexdump.h> 35#include <media/stagefright/foundation/ABuffer.h> 36#include <media/stagefright/foundation/ADebug.h> 37#include <media/stagefright/foundation/AMessage.h> 38#include <media/stagefright/MediaDefs.h> 39#include <media/stagefright/MediaErrors.h> 40#include <media/stagefright/MetaData.h> 41#include <gui/IGraphicBufferProducer.h> 42 43#include "avc_utils.h" 44 45#include "ESDS.h" 46#include <media/stagefright/Utils.h> 47 48namespace android { 49 50struct NuPlayer::Action : public RefBase { 51 Action() {} 52 53 virtual void execute(NuPlayer *player) = 0; 54 55private: 56 DISALLOW_EVIL_CONSTRUCTORS(Action); 57}; 58 59struct NuPlayer::SeekAction : public Action { 60 SeekAction(int64_t seekTimeUs) 61 : mSeekTimeUs(seekTimeUs) { 62 } 63 64 virtual void execute(NuPlayer *player) { 65 player->performSeek(mSeekTimeUs); 66 } 67 68private: 69 int64_t mSeekTimeUs; 70 71 DISALLOW_EVIL_CONSTRUCTORS(SeekAction); 72}; 73 74struct NuPlayer::SetSurfaceAction : public Action { 75 SetSurfaceAction(const sp<NativeWindowWrapper> &wrapper) 76 : mWrapper(wrapper) { 77 } 78 79 virtual void execute(NuPlayer *player) { 80 player->performSetSurface(mWrapper); 81 } 82 83private: 84 sp<NativeWindowWrapper> mWrapper; 85 86 DISALLOW_EVIL_CONSTRUCTORS(SetSurfaceAction); 87}; 88 89struct NuPlayer::ShutdownDecoderAction : public Action { 90 ShutdownDecoderAction(bool audio, bool video) 91 : mAudio(audio), 92 mVideo(video) { 93 } 94 95 virtual void execute(NuPlayer *player) { 96 player->performDecoderShutdown(mAudio, mVideo); 97 } 98 99private: 100 bool mAudio; 101 bool mVideo; 102 103 DISALLOW_EVIL_CONSTRUCTORS(ShutdownDecoderAction); 104}; 105 106struct NuPlayer::PostMessageAction : public Action { 107 PostMessageAction(const sp<AMessage> &msg) 108 : mMessage(msg) { 109 } 110 111 virtual void execute(NuPlayer *) { 112 mMessage->post(); 113 } 114 115private: 116 sp<AMessage> mMessage; 117 118 DISALLOW_EVIL_CONSTRUCTORS(PostMessageAction); 119}; 120 121// Use this if there's no state necessary to save in order to execute 122// the action. 123struct NuPlayer::SimpleAction : public Action { 124 typedef void (NuPlayer::*ActionFunc)(); 125 126 SimpleAction(ActionFunc func) 127 : mFunc(func) { 128 } 129 130 virtual void execute(NuPlayer *player) { 131 (player->*mFunc)(); 132 } 133 134private: 135 ActionFunc mFunc; 136 137 DISALLOW_EVIL_CONSTRUCTORS(SimpleAction); 138}; 139 140//////////////////////////////////////////////////////////////////////////////// 141 142NuPlayer::NuPlayer() 143 : mUIDValid(false), 144 mSourceFlags(0), 145 mVideoIsAVC(false), 146 mAudioEOS(false), 147 mVideoEOS(false), 148 mScanSourcesPending(false), 149 mScanSourcesGeneration(0), 150 mPollDurationGeneration(0), 151 mTimeDiscontinuityPending(false), 152 mFlushingAudio(NONE), 153 mFlushingVideo(NONE), 154 mSkipRenderingAudioUntilMediaTimeUs(-1ll), 155 mSkipRenderingVideoUntilMediaTimeUs(-1ll), 156 mVideoLateByUs(0ll), 157 mNumFramesTotal(0ll), 158 mNumFramesDropped(0ll), 159 mVideoScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW), 160 mStarted(false) { 161} 162 163NuPlayer::~NuPlayer() { 164} 165 166void NuPlayer::setUID(uid_t uid) { 167 mUIDValid = true; 168 mUID = uid; 169} 170 171void NuPlayer::setDriver(const wp<NuPlayerDriver> &driver) { 172 mDriver = driver; 173} 174 175void NuPlayer::setDataSourceAsync(const sp<IStreamSource> &source) { 176 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id()); 177 178 sp<AMessage> notify = new AMessage(kWhatSourceNotify, id()); 179 180 msg->setObject("source", new StreamingSource(notify, source)); 181 msg->post(); 182} 183 184static bool IsHTTPLiveURL(const char *url) { 185 if (!strncasecmp("http://", url, 7) 186 || !strncasecmp("https://", url, 8) 187 || !strncasecmp("file://", url, 7)) { 188 size_t len = strlen(url); 189 if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) { 190 return true; 191 } 192 193 if (strstr(url,"m3u8")) { 194 return true; 195 } 196 } 197 198 return false; 199} 200 201void NuPlayer::setDataSourceAsync( 202 const sp<IMediaHTTPService> &httpService, 203 const char *url, 204 const KeyedVector<String8, String8> *headers) { 205 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id()); 206 size_t len = strlen(url); 207 208 sp<AMessage> notify = new AMessage(kWhatSourceNotify, id()); 209 210 sp<Source> source; 211 if (IsHTTPLiveURL(url)) { 212 source = new HTTPLiveSource(notify, httpService, url, headers); 213 } else if (!strncasecmp(url, "rtsp://", 7)) { 214 source = new RTSPSource( 215 notify, httpService, url, headers, mUIDValid, mUID); 216 } else if ((!strncasecmp(url, "http://", 7) 217 || !strncasecmp(url, "https://", 8)) 218 && ((len >= 4 && !strcasecmp(".sdp", &url[len - 4])) 219 || strstr(url, ".sdp?"))) { 220 source = new RTSPSource( 221 notify, httpService, url, headers, mUIDValid, mUID, true); 222 } else { 223 source = new GenericSource(notify, httpService, url, headers); 224 } 225 226 msg->setObject("source", source); 227 msg->post(); 228} 229 230void NuPlayer::setDataSourceAsync(int fd, int64_t offset, int64_t length) { 231 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id()); 232 233 sp<AMessage> notify = new AMessage(kWhatSourceNotify, id()); 234 235 sp<Source> source = new GenericSource(notify, fd, offset, length); 236 msg->setObject("source", source); 237 msg->post(); 238} 239 240void NuPlayer::prepareAsync() { 241 (new AMessage(kWhatPrepare, id()))->post(); 242} 243 244void NuPlayer::setVideoSurfaceTextureAsync( 245 const sp<IGraphicBufferProducer> &bufferProducer) { 246 sp<AMessage> msg = new AMessage(kWhatSetVideoNativeWindow, id()); 247 248 if (bufferProducer == NULL) { 249 msg->setObject("native-window", NULL); 250 } else { 251 msg->setObject( 252 "native-window", 253 new NativeWindowWrapper( 254 new Surface(bufferProducer))); 255 } 256 257 msg->post(); 258} 259 260void NuPlayer::setAudioSink(const sp<MediaPlayerBase::AudioSink> &sink) { 261 sp<AMessage> msg = new AMessage(kWhatSetAudioSink, id()); 262 msg->setObject("sink", sink); 263 msg->post(); 264} 265 266void NuPlayer::start() { 267 (new AMessage(kWhatStart, id()))->post(); 268} 269 270void NuPlayer::pause() { 271 (new AMessage(kWhatPause, id()))->post(); 272} 273 274void NuPlayer::resume() { 275 (new AMessage(kWhatResume, id()))->post(); 276} 277 278void NuPlayer::resetAsync() { 279 (new AMessage(kWhatReset, id()))->post(); 280} 281 282void NuPlayer::seekToAsync(int64_t seekTimeUs) { 283 sp<AMessage> msg = new AMessage(kWhatSeek, id()); 284 msg->setInt64("seekTimeUs", seekTimeUs); 285 msg->post(); 286} 287 288// static 289bool NuPlayer::IsFlushingState(FlushStatus state, bool *needShutdown) { 290 switch (state) { 291 case FLUSHING_DECODER: 292 if (needShutdown != NULL) { 293 *needShutdown = false; 294 } 295 return true; 296 297 case FLUSHING_DECODER_SHUTDOWN: 298 if (needShutdown != NULL) { 299 *needShutdown = true; 300 } 301 return true; 302 303 default: 304 return false; 305 } 306} 307 308void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { 309 switch (msg->what()) { 310 case kWhatSetDataSource: 311 { 312 ALOGV("kWhatSetDataSource"); 313 314 CHECK(mSource == NULL); 315 316 sp<RefBase> obj; 317 CHECK(msg->findObject("source", &obj)); 318 319 mSource = static_cast<Source *>(obj.get()); 320 321 looper()->registerHandler(mSource); 322 323 CHECK(mDriver != NULL); 324 sp<NuPlayerDriver> driver = mDriver.promote(); 325 if (driver != NULL) { 326 driver->notifySetDataSourceCompleted(OK); 327 } 328 break; 329 } 330 331 case kWhatPrepare: 332 { 333 mSource->prepareAsync(); 334 break; 335 } 336 337 case kWhatGetTrackInfo: 338 { 339 uint32_t replyID; 340 CHECK(msg->senderAwaitsResponse(&replyID)); 341 342 status_t err = INVALID_OPERATION; 343 if (mSource != NULL) { 344 Parcel* reply; 345 CHECK(msg->findPointer("reply", (void**)&reply)); 346 err = mSource->getTrackInfo(reply); 347 } 348 349 sp<AMessage> response = new AMessage; 350 response->setInt32("err", err); 351 352 response->postReply(replyID); 353 break; 354 } 355 356 case kWhatSelectTrack: 357 { 358 uint32_t replyID; 359 CHECK(msg->senderAwaitsResponse(&replyID)); 360 361 status_t err = INVALID_OPERATION; 362 if (mSource != NULL) { 363 size_t trackIndex; 364 int32_t select; 365 CHECK(msg->findSize("trackIndex", &trackIndex)); 366 CHECK(msg->findInt32("select", &select)); 367 err = mSource->selectTrack(trackIndex, select); 368 } 369 370 sp<AMessage> response = new AMessage; 371 response->setInt32("err", err); 372 373 response->postReply(replyID); 374 break; 375 } 376 377 case kWhatPollDuration: 378 { 379 int32_t generation; 380 CHECK(msg->findInt32("generation", &generation)); 381 382 if (generation != mPollDurationGeneration) { 383 // stale 384 break; 385 } 386 387 int64_t durationUs; 388 if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) { 389 sp<NuPlayerDriver> driver = mDriver.promote(); 390 if (driver != NULL) { 391 driver->notifyDuration(durationUs); 392 } 393 } 394 395 msg->post(1000000ll); // poll again in a second. 396 break; 397 } 398 399 case kWhatSetVideoNativeWindow: 400 { 401 ALOGV("kWhatSetVideoNativeWindow"); 402 403 mDeferredActions.push_back( 404 new ShutdownDecoderAction( 405 false /* audio */, true /* video */)); 406 407 sp<RefBase> obj; 408 CHECK(msg->findObject("native-window", &obj)); 409 410 mDeferredActions.push_back( 411 new SetSurfaceAction( 412 static_cast<NativeWindowWrapper *>(obj.get()))); 413 414 if (obj != NULL) { 415 // If there is a new surface texture, instantiate decoders 416 // again if possible. 417 mDeferredActions.push_back( 418 new SimpleAction(&NuPlayer::performScanSources)); 419 } 420 421 processDeferredActions(); 422 break; 423 } 424 425 case kWhatSetAudioSink: 426 { 427 ALOGV("kWhatSetAudioSink"); 428 429 sp<RefBase> obj; 430 CHECK(msg->findObject("sink", &obj)); 431 432 mAudioSink = static_cast<MediaPlayerBase::AudioSink *>(obj.get()); 433 break; 434 } 435 436 case kWhatStart: 437 { 438 ALOGV("kWhatStart"); 439 440 mVideoIsAVC = false; 441 mAudioEOS = false; 442 mVideoEOS = false; 443 mSkipRenderingAudioUntilMediaTimeUs = -1; 444 mSkipRenderingVideoUntilMediaTimeUs = -1; 445 mVideoLateByUs = 0; 446 mNumFramesTotal = 0; 447 mNumFramesDropped = 0; 448 mStarted = true; 449 450 mSource->start(); 451 452 uint32_t flags = 0; 453 454 if (mSource->isRealTime()) { 455 flags |= Renderer::FLAG_REAL_TIME; 456 } 457 458 mRenderer = new Renderer( 459 mAudioSink, 460 new AMessage(kWhatRendererNotify, id()), 461 flags); 462 463 looper()->registerHandler(mRenderer); 464 465 postScanSources(); 466 break; 467 } 468 469 case kWhatScanSources: 470 { 471 int32_t generation; 472 CHECK(msg->findInt32("generation", &generation)); 473 if (generation != mScanSourcesGeneration) { 474 // Drop obsolete msg. 475 break; 476 } 477 478 mScanSourcesPending = false; 479 480 ALOGV("scanning sources haveAudio=%d, haveVideo=%d", 481 mAudioDecoder != NULL, mVideoDecoder != NULL); 482 483 bool mHadAnySourcesBefore = 484 (mAudioDecoder != NULL) || (mVideoDecoder != NULL); 485 486 if (mNativeWindow != NULL) { 487 instantiateDecoder(false, &mVideoDecoder); 488 } 489 490 if (mAudioSink != NULL) { 491 instantiateDecoder(true, &mAudioDecoder); 492 } 493 494 if (!mHadAnySourcesBefore 495 && (mAudioDecoder != NULL || mVideoDecoder != NULL)) { 496 // This is the first time we've found anything playable. 497 498 if (mSourceFlags & Source::FLAG_DYNAMIC_DURATION) { 499 schedulePollDuration(); 500 } 501 } 502 503 status_t err; 504 if ((err = mSource->feedMoreTSData()) != OK) { 505 if (mAudioDecoder == NULL && mVideoDecoder == NULL) { 506 // We're not currently decoding anything (no audio or 507 // video tracks found) and we just ran out of input data. 508 509 if (err == ERROR_END_OF_STREAM) { 510 notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0); 511 } else { 512 notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err); 513 } 514 } 515 break; 516 } 517 518 if ((mAudioDecoder == NULL && mAudioSink != NULL) 519 || (mVideoDecoder == NULL && mNativeWindow != NULL)) { 520 msg->post(100000ll); 521 mScanSourcesPending = true; 522 } 523 break; 524 } 525 526 case kWhatVideoNotify: 527 case kWhatAudioNotify: 528 { 529 bool audio = msg->what() == kWhatAudioNotify; 530 531 int32_t what; 532 CHECK(msg->findInt32("what", &what)); 533 534 if (what == Decoder::kWhatFillThisBuffer) { 535 status_t err = feedDecoderInputData( 536 audio, msg); 537 538 if (err == -EWOULDBLOCK) { 539 if (mSource->feedMoreTSData() == OK) { 540 msg->post(10000ll); 541 } 542 } 543 } else if (what == Decoder::kWhatEOS) { 544 int32_t err; 545 CHECK(msg->findInt32("err", &err)); 546 547 if (err == ERROR_END_OF_STREAM) { 548 ALOGV("got %s decoder EOS", audio ? "audio" : "video"); 549 } else { 550 ALOGV("got %s decoder EOS w/ error %d", 551 audio ? "audio" : "video", 552 err); 553 } 554 555 mRenderer->queueEOS(audio, err); 556 } else if (what == Decoder::kWhatFlushCompleted) { 557 bool needShutdown; 558 559 if (audio) { 560 CHECK(IsFlushingState(mFlushingAudio, &needShutdown)); 561 mFlushingAudio = FLUSHED; 562 } else { 563 CHECK(IsFlushingState(mFlushingVideo, &needShutdown)); 564 mFlushingVideo = FLUSHED; 565 566 mVideoLateByUs = 0; 567 } 568 569 ALOGV("decoder %s flush completed", audio ? "audio" : "video"); 570 571 if (needShutdown) { 572 ALOGV("initiating %s decoder shutdown", 573 audio ? "audio" : "video"); 574 575 (audio ? mAudioDecoder : mVideoDecoder)->initiateShutdown(); 576 577 if (audio) { 578 mFlushingAudio = SHUTTING_DOWN_DECODER; 579 } else { 580 mFlushingVideo = SHUTTING_DOWN_DECODER; 581 } 582 } 583 584 finishFlushIfPossible(); 585 } else if (what == Decoder::kWhatOutputFormatChanged) { 586 sp<AMessage> format; 587 CHECK(msg->findMessage("format", &format)); 588 589 if (audio) { 590 int32_t numChannels; 591 CHECK(format->findInt32( 592 "channel-count", &numChannels)); 593 594 int32_t sampleRate; 595 CHECK(format->findInt32("sample-rate", &sampleRate)); 596 597 ALOGV("Audio output format changed to %d Hz, %d channels", 598 sampleRate, numChannels); 599 600 mAudioSink->close(); 601 602 audio_output_flags_t flags; 603 int64_t durationUs; 604 // FIXME: we should handle the case where the video decoder 605 // is created after we receive the format change indication. 606 // Current code will just make that we select deep buffer 607 // with video which should not be a problem as it should 608 // not prevent from keeping A/V sync. 609 if (mVideoDecoder == NULL && 610 mSource->getDuration(&durationUs) == OK && 611 durationUs 612 > AUDIO_SINK_MIN_DEEP_BUFFER_DURATION_US) { 613 flags = AUDIO_OUTPUT_FLAG_DEEP_BUFFER; 614 } else { 615 flags = AUDIO_OUTPUT_FLAG_NONE; 616 } 617 618 int32_t channelMask; 619 if (!format->findInt32("channel-mask", &channelMask)) { 620 channelMask = CHANNEL_MASK_USE_CHANNEL_ORDER; 621 } 622 623 CHECK_EQ(mAudioSink->open( 624 sampleRate, 625 numChannels, 626 (audio_channel_mask_t)channelMask, 627 AUDIO_FORMAT_PCM_16_BIT, 628 8 /* bufferCount */, 629 NULL, 630 NULL, 631 flags), 632 (status_t)OK); 633 mAudioSink->start(); 634 635 mRenderer->signalAudioSinkChanged(); 636 } else { 637 // video 638 639 int32_t width, height; 640 CHECK(format->findInt32("width", &width)); 641 CHECK(format->findInt32("height", &height)); 642 643 int32_t cropLeft, cropTop, cropRight, cropBottom; 644 CHECK(format->findRect( 645 "crop", 646 &cropLeft, &cropTop, &cropRight, &cropBottom)); 647 648 int32_t displayWidth = cropRight - cropLeft + 1; 649 int32_t displayHeight = cropBottom - cropTop + 1; 650 651 ALOGV("Video output format changed to %d x %d " 652 "(crop: %d x %d @ (%d, %d))", 653 width, height, 654 displayWidth, 655 displayHeight, 656 cropLeft, cropTop); 657 658 sp<AMessage> videoInputFormat = 659 mSource->getFormat(false /* audio */); 660 661 // Take into account sample aspect ratio if necessary: 662 int32_t sarWidth, sarHeight; 663 if (videoInputFormat->findInt32("sar-width", &sarWidth) 664 && videoInputFormat->findInt32( 665 "sar-height", &sarHeight)) { 666 ALOGV("Sample aspect ratio %d : %d", 667 sarWidth, sarHeight); 668 669 displayWidth = (displayWidth * sarWidth) / sarHeight; 670 671 ALOGV("display dimensions %d x %d", 672 displayWidth, displayHeight); 673 } 674 675 notifyListener( 676 MEDIA_SET_VIDEO_SIZE, displayWidth, displayHeight); 677 } 678 } else if (what == Decoder::kWhatShutdownCompleted) { 679 ALOGV("%s shutdown completed", audio ? "audio" : "video"); 680 if (audio) { 681 mAudioDecoder.clear(); 682 683 CHECK_EQ((int)mFlushingAudio, (int)SHUTTING_DOWN_DECODER); 684 mFlushingAudio = SHUT_DOWN; 685 } else { 686 mVideoDecoder.clear(); 687 688 CHECK_EQ((int)mFlushingVideo, (int)SHUTTING_DOWN_DECODER); 689 mFlushingVideo = SHUT_DOWN; 690 } 691 692 finishFlushIfPossible(); 693 } else if (what == Decoder::kWhatError) { 694 ALOGE("Received error from %s decoder, aborting playback.", 695 audio ? "audio" : "video"); 696 697 mRenderer->queueEOS(audio, UNKNOWN_ERROR); 698 } else if (what == Decoder::kWhatDrainThisBuffer) { 699 renderBuffer(audio, msg); 700 } else { 701 ALOGV("Unhandled decoder notification %d '%c%c%c%c'.", 702 what, 703 what >> 24, 704 (what >> 16) & 0xff, 705 (what >> 8) & 0xff, 706 what & 0xff); 707 } 708 709 break; 710 } 711 712 case kWhatRendererNotify: 713 { 714 int32_t what; 715 CHECK(msg->findInt32("what", &what)); 716 717 if (what == Renderer::kWhatEOS) { 718 int32_t audio; 719 CHECK(msg->findInt32("audio", &audio)); 720 721 int32_t finalResult; 722 CHECK(msg->findInt32("finalResult", &finalResult)); 723 724 if (audio) { 725 mAudioEOS = true; 726 } else { 727 mVideoEOS = true; 728 } 729 730 if (finalResult == ERROR_END_OF_STREAM) { 731 ALOGV("reached %s EOS", audio ? "audio" : "video"); 732 } else { 733 ALOGE("%s track encountered an error (%d)", 734 audio ? "audio" : "video", finalResult); 735 736 notifyListener( 737 MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, finalResult); 738 } 739 740 if ((mAudioEOS || mAudioDecoder == NULL) 741 && (mVideoEOS || mVideoDecoder == NULL)) { 742 notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0); 743 } 744 } else if (what == Renderer::kWhatPosition) { 745 int64_t positionUs; 746 CHECK(msg->findInt64("positionUs", &positionUs)); 747 748 CHECK(msg->findInt64("videoLateByUs", &mVideoLateByUs)); 749 750 if (mDriver != NULL) { 751 sp<NuPlayerDriver> driver = mDriver.promote(); 752 if (driver != NULL) { 753 driver->notifyPosition(positionUs); 754 755 driver->notifyFrameStats( 756 mNumFramesTotal, mNumFramesDropped); 757 } 758 } 759 } else if (what == Renderer::kWhatFlushComplete) { 760 int32_t audio; 761 CHECK(msg->findInt32("audio", &audio)); 762 763 ALOGV("renderer %s flush completed.", audio ? "audio" : "video"); 764 } else if (what == Renderer::kWhatVideoRenderingStart) { 765 notifyListener(MEDIA_INFO, MEDIA_INFO_RENDERING_START, 0); 766 } else if (what == Renderer::kWhatMediaRenderingStart) { 767 ALOGV("media rendering started"); 768 notifyListener(MEDIA_STARTED, 0, 0); 769 } 770 break; 771 } 772 773 case kWhatMoreDataQueued: 774 { 775 break; 776 } 777 778 case kWhatReset: 779 { 780 ALOGV("kWhatReset"); 781 782 mDeferredActions.push_back( 783 new ShutdownDecoderAction( 784 true /* audio */, true /* video */)); 785 786 mDeferredActions.push_back( 787 new SimpleAction(&NuPlayer::performReset)); 788 789 processDeferredActions(); 790 break; 791 } 792 793 case kWhatSeek: 794 { 795 int64_t seekTimeUs; 796 CHECK(msg->findInt64("seekTimeUs", &seekTimeUs)); 797 798 ALOGV("kWhatSeek seekTimeUs=%lld us", seekTimeUs); 799 800 mDeferredActions.push_back( 801 new SimpleAction(&NuPlayer::performDecoderFlush)); 802 803 mDeferredActions.push_back(new SeekAction(seekTimeUs)); 804 805 processDeferredActions(); 806 break; 807 } 808 809 case kWhatPause: 810 { 811 CHECK(mRenderer != NULL); 812 mSource->pause(); 813 mRenderer->pause(); 814 break; 815 } 816 817 case kWhatResume: 818 { 819 CHECK(mRenderer != NULL); 820 mSource->resume(); 821 mRenderer->resume(); 822 break; 823 } 824 825 case kWhatSourceNotify: 826 { 827 onSourceNotify(msg); 828 break; 829 } 830 831 default: 832 TRESPASS(); 833 break; 834 } 835} 836 837void NuPlayer::finishFlushIfPossible() { 838 if (mFlushingAudio != FLUSHED && mFlushingAudio != SHUT_DOWN) { 839 return; 840 } 841 842 if (mFlushingVideo != FLUSHED && mFlushingVideo != SHUT_DOWN) { 843 return; 844 } 845 846 ALOGV("both audio and video are flushed now."); 847 848 if (mTimeDiscontinuityPending) { 849 mRenderer->signalTimeDiscontinuity(); 850 mTimeDiscontinuityPending = false; 851 } 852 853 if (mAudioDecoder != NULL) { 854 mAudioDecoder->signalResume(); 855 } 856 857 if (mVideoDecoder != NULL) { 858 mVideoDecoder->signalResume(); 859 } 860 861 mFlushingAudio = NONE; 862 mFlushingVideo = NONE; 863 864 processDeferredActions(); 865} 866 867void NuPlayer::postScanSources() { 868 if (mScanSourcesPending) { 869 return; 870 } 871 872 sp<AMessage> msg = new AMessage(kWhatScanSources, id()); 873 msg->setInt32("generation", mScanSourcesGeneration); 874 msg->post(); 875 876 mScanSourcesPending = true; 877} 878 879status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) { 880 if (*decoder != NULL) { 881 return OK; 882 } 883 884 sp<AMessage> format = mSource->getFormat(audio); 885 886 if (format == NULL) { 887 return -EWOULDBLOCK; 888 } 889 890 if (!audio) { 891 AString mime; 892 CHECK(format->findString("mime", &mime)); 893 mVideoIsAVC = !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime.c_str()); 894 } 895 896 sp<AMessage> notify = 897 new AMessage(audio ? kWhatAudioNotify : kWhatVideoNotify, 898 id()); 899 900 *decoder = audio ? new Decoder(notify) : 901 new Decoder(notify, mNativeWindow); 902 (*decoder)->init(); 903 (*decoder)->configure(format); 904 905 return OK; 906} 907 908status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) { 909 sp<AMessage> reply; 910 CHECK(msg->findMessage("reply", &reply)); 911 912 if ((audio && IsFlushingState(mFlushingAudio)) 913 || (!audio && IsFlushingState(mFlushingVideo))) { 914 reply->setInt32("err", INFO_DISCONTINUITY); 915 reply->post(); 916 return OK; 917 } 918 919 sp<ABuffer> accessUnit; 920 921 bool dropAccessUnit; 922 do { 923 status_t err = mSource->dequeueAccessUnit(audio, &accessUnit); 924 925 if (err == -EWOULDBLOCK) { 926 return err; 927 } else if (err != OK) { 928 if (err == INFO_DISCONTINUITY) { 929 int32_t type; 930 CHECK(accessUnit->meta()->findInt32("discontinuity", &type)); 931 932 bool formatChange = 933 (audio && 934 (type & ATSParser::DISCONTINUITY_AUDIO_FORMAT)) 935 || (!audio && 936 (type & ATSParser::DISCONTINUITY_VIDEO_FORMAT)); 937 938 bool timeChange = (type & ATSParser::DISCONTINUITY_TIME) != 0; 939 940 ALOGI("%s discontinuity (formatChange=%d, time=%d)", 941 audio ? "audio" : "video", formatChange, timeChange); 942 943 if (audio) { 944 mSkipRenderingAudioUntilMediaTimeUs = -1; 945 } else { 946 mSkipRenderingVideoUntilMediaTimeUs = -1; 947 } 948 949 if (timeChange) { 950 sp<AMessage> extra; 951 if (accessUnit->meta()->findMessage("extra", &extra) 952 && extra != NULL) { 953 int64_t resumeAtMediaTimeUs; 954 if (extra->findInt64( 955 "resume-at-mediatimeUs", &resumeAtMediaTimeUs)) { 956 ALOGI("suppressing rendering of %s until %lld us", 957 audio ? "audio" : "video", resumeAtMediaTimeUs); 958 959 if (audio) { 960 mSkipRenderingAudioUntilMediaTimeUs = 961 resumeAtMediaTimeUs; 962 } else { 963 mSkipRenderingVideoUntilMediaTimeUs = 964 resumeAtMediaTimeUs; 965 } 966 } 967 } 968 } 969 970 mTimeDiscontinuityPending = 971 mTimeDiscontinuityPending || timeChange; 972 973 if (formatChange || timeChange) { 974 if (mFlushingAudio == NONE && mFlushingVideo == NONE) { 975 // And we'll resume scanning sources once we're done 976 // flushing. 977 mDeferredActions.push_front( 978 new SimpleAction( 979 &NuPlayer::performScanSources)); 980 } 981 982 sp<AMessage> newFormat = mSource->getFormat(audio); 983 sp<Decoder> &decoder = audio ? mAudioDecoder : mVideoDecoder; 984 if (formatChange && !decoder->supportsSeamlessFormatChange(newFormat)) { 985 flushDecoder(audio, /* needShutdown = */ true); 986 } else { 987 flushDecoder(audio, /* needShutdown = */ false); 988 err = OK; 989 } 990 } else { 991 // This stream is unaffected by the discontinuity 992 993 if (audio) { 994 mFlushingAudio = FLUSHED; 995 } else { 996 mFlushingVideo = FLUSHED; 997 } 998 999 finishFlushIfPossible(); 1000 1001 return -EWOULDBLOCK; 1002 } 1003 } 1004 1005 reply->setInt32("err", err); 1006 reply->post(); 1007 return OK; 1008 } 1009 1010 if (!audio) { 1011 ++mNumFramesTotal; 1012 } 1013 1014 dropAccessUnit = false; 1015 if (!audio 1016 && mVideoLateByUs > 100000ll 1017 && mVideoIsAVC 1018 && !IsAVCReferenceFrame(accessUnit)) { 1019 dropAccessUnit = true; 1020 ++mNumFramesDropped; 1021 } 1022 } while (dropAccessUnit); 1023 1024 // ALOGV("returned a valid buffer of %s data", audio ? "audio" : "video"); 1025 1026#if 0 1027 int64_t mediaTimeUs; 1028 CHECK(accessUnit->meta()->findInt64("timeUs", &mediaTimeUs)); 1029 ALOGV("feeding %s input buffer at media time %.2f secs", 1030 audio ? "audio" : "video", 1031 mediaTimeUs / 1E6); 1032#endif 1033 1034 reply->setBuffer("buffer", accessUnit); 1035 reply->post(); 1036 1037 return OK; 1038} 1039 1040void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) { 1041 // ALOGV("renderBuffer %s", audio ? "audio" : "video"); 1042 1043 sp<AMessage> reply; 1044 CHECK(msg->findMessage("reply", &reply)); 1045 1046 if (IsFlushingState(audio ? mFlushingAudio : mFlushingVideo)) { 1047 // We're currently attempting to flush the decoder, in order 1048 // to complete this, the decoder wants all its buffers back, 1049 // so we don't want any output buffers it sent us (from before 1050 // we initiated the flush) to be stuck in the renderer's queue. 1051 1052 ALOGV("we're still flushing the %s decoder, sending its output buffer" 1053 " right back.", audio ? "audio" : "video"); 1054 1055 reply->post(); 1056 return; 1057 } 1058 1059 sp<ABuffer> buffer; 1060 CHECK(msg->findBuffer("buffer", &buffer)); 1061 1062 int64_t &skipUntilMediaTimeUs = 1063 audio 1064 ? mSkipRenderingAudioUntilMediaTimeUs 1065 : mSkipRenderingVideoUntilMediaTimeUs; 1066 1067 if (skipUntilMediaTimeUs >= 0) { 1068 int64_t mediaTimeUs; 1069 CHECK(buffer->meta()->findInt64("timeUs", &mediaTimeUs)); 1070 1071 if (mediaTimeUs < skipUntilMediaTimeUs) { 1072 ALOGV("dropping %s buffer at time %lld as requested.", 1073 audio ? "audio" : "video", 1074 mediaTimeUs); 1075 1076 reply->post(); 1077 return; 1078 } 1079 1080 skipUntilMediaTimeUs = -1; 1081 } 1082 1083 mRenderer->queueBuffer(audio, buffer, reply); 1084} 1085 1086void NuPlayer::notifyListener(int msg, int ext1, int ext2, const Parcel *in) { 1087 if (mDriver == NULL) { 1088 return; 1089 } 1090 1091 sp<NuPlayerDriver> driver = mDriver.promote(); 1092 1093 if (driver == NULL) { 1094 return; 1095 } 1096 1097 driver->notifyListener(msg, ext1, ext2, in); 1098} 1099 1100void NuPlayer::flushDecoder(bool audio, bool needShutdown) { 1101 ALOGV("[%s] flushDecoder needShutdown=%d", 1102 audio ? "audio" : "video", needShutdown); 1103 1104 if ((audio && mAudioDecoder == NULL) || (!audio && mVideoDecoder == NULL)) { 1105 ALOGI("flushDecoder %s without decoder present", 1106 audio ? "audio" : "video"); 1107 } 1108 1109 // Make sure we don't continue to scan sources until we finish flushing. 1110 ++mScanSourcesGeneration; 1111 mScanSourcesPending = false; 1112 1113 (audio ? mAudioDecoder : mVideoDecoder)->signalFlush(); 1114 mRenderer->flush(audio); 1115 1116 FlushStatus newStatus = 1117 needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER; 1118 1119 if (audio) { 1120 CHECK(mFlushingAudio == NONE 1121 || mFlushingAudio == AWAITING_DISCONTINUITY); 1122 1123 mFlushingAudio = newStatus; 1124 1125 if (mFlushingVideo == NONE) { 1126 mFlushingVideo = (mVideoDecoder != NULL) 1127 ? AWAITING_DISCONTINUITY 1128 : FLUSHED; 1129 } 1130 } else { 1131 CHECK(mFlushingVideo == NONE 1132 || mFlushingVideo == AWAITING_DISCONTINUITY); 1133 1134 mFlushingVideo = newStatus; 1135 1136 if (mFlushingAudio == NONE) { 1137 mFlushingAudio = (mAudioDecoder != NULL) 1138 ? AWAITING_DISCONTINUITY 1139 : FLUSHED; 1140 } 1141 } 1142} 1143 1144sp<AMessage> NuPlayer::Source::getFormat(bool audio) { 1145 sp<MetaData> meta = getFormatMeta(audio); 1146 1147 if (meta == NULL) { 1148 return NULL; 1149 } 1150 1151 sp<AMessage> msg = new AMessage; 1152 1153 if(convertMetaDataToMessage(meta, &msg) == OK) { 1154 return msg; 1155 } 1156 return NULL; 1157} 1158 1159status_t NuPlayer::setVideoScalingMode(int32_t mode) { 1160 mVideoScalingMode = mode; 1161 if (mNativeWindow != NULL) { 1162 status_t ret = native_window_set_scaling_mode( 1163 mNativeWindow->getNativeWindow().get(), mVideoScalingMode); 1164 if (ret != OK) { 1165 ALOGE("Failed to set scaling mode (%d): %s", 1166 -ret, strerror(-ret)); 1167 return ret; 1168 } 1169 } 1170 return OK; 1171} 1172 1173status_t NuPlayer::getTrackInfo(Parcel* reply) const { 1174 sp<AMessage> msg = new AMessage(kWhatGetTrackInfo, id()); 1175 msg->setPointer("reply", reply); 1176 1177 sp<AMessage> response; 1178 status_t err = msg->postAndAwaitResponse(&response); 1179 return err; 1180} 1181 1182status_t NuPlayer::selectTrack(size_t trackIndex, bool select) { 1183 sp<AMessage> msg = new AMessage(kWhatSelectTrack, id()); 1184 msg->setSize("trackIndex", trackIndex); 1185 msg->setInt32("select", select); 1186 1187 sp<AMessage> response; 1188 status_t err = msg->postAndAwaitResponse(&response); 1189 1190 return err; 1191} 1192 1193void NuPlayer::schedulePollDuration() { 1194 sp<AMessage> msg = new AMessage(kWhatPollDuration, id()); 1195 msg->setInt32("generation", mPollDurationGeneration); 1196 msg->post(); 1197} 1198 1199void NuPlayer::cancelPollDuration() { 1200 ++mPollDurationGeneration; 1201} 1202 1203void NuPlayer::processDeferredActions() { 1204 while (!mDeferredActions.empty()) { 1205 // We won't execute any deferred actions until we're no longer in 1206 // an intermediate state, i.e. one more more decoders are currently 1207 // flushing or shutting down. 1208 1209 if (mRenderer != NULL) { 1210 // There's an edge case where the renderer owns all output 1211 // buffers and is paused, therefore the decoder will not read 1212 // more input data and will never encounter the matching 1213 // discontinuity. To avoid this, we resume the renderer. 1214 1215 if (mFlushingAudio == AWAITING_DISCONTINUITY 1216 || mFlushingVideo == AWAITING_DISCONTINUITY) { 1217 mRenderer->resume(); 1218 } 1219 } 1220 1221 if (mFlushingAudio != NONE || mFlushingVideo != NONE) { 1222 // We're currently flushing, postpone the reset until that's 1223 // completed. 1224 1225 ALOGV("postponing action mFlushingAudio=%d, mFlushingVideo=%d", 1226 mFlushingAudio, mFlushingVideo); 1227 1228 break; 1229 } 1230 1231 sp<Action> action = *mDeferredActions.begin(); 1232 mDeferredActions.erase(mDeferredActions.begin()); 1233 1234 action->execute(this); 1235 } 1236} 1237 1238void NuPlayer::performSeek(int64_t seekTimeUs) { 1239 ALOGV("performSeek seekTimeUs=%lld us (%.2f secs)", 1240 seekTimeUs, 1241 seekTimeUs / 1E6); 1242 1243 mSource->seekTo(seekTimeUs); 1244 1245 if (mDriver != NULL) { 1246 sp<NuPlayerDriver> driver = mDriver.promote(); 1247 if (driver != NULL) { 1248 driver->notifyPosition(seekTimeUs); 1249 driver->notifySeekComplete(); 1250 } 1251 } 1252 1253 // everything's flushed, continue playback. 1254} 1255 1256void NuPlayer::performDecoderFlush() { 1257 ALOGV("performDecoderFlush"); 1258 1259 if (mAudioDecoder == NULL && mVideoDecoder == NULL) { 1260 return; 1261 } 1262 1263 mTimeDiscontinuityPending = true; 1264 1265 if (mAudioDecoder != NULL) { 1266 flushDecoder(true /* audio */, false /* needShutdown */); 1267 } 1268 1269 if (mVideoDecoder != NULL) { 1270 flushDecoder(false /* audio */, false /* needShutdown */); 1271 } 1272} 1273 1274void NuPlayer::performDecoderShutdown(bool audio, bool video) { 1275 ALOGV("performDecoderShutdown audio=%d, video=%d", audio, video); 1276 1277 if ((!audio || mAudioDecoder == NULL) 1278 && (!video || mVideoDecoder == NULL)) { 1279 return; 1280 } 1281 1282 mTimeDiscontinuityPending = true; 1283 1284 if (mFlushingAudio == NONE && (!audio || mAudioDecoder == NULL)) { 1285 mFlushingAudio = FLUSHED; 1286 } 1287 1288 if (mFlushingVideo == NONE && (!video || mVideoDecoder == NULL)) { 1289 mFlushingVideo = FLUSHED; 1290 } 1291 1292 if (audio && mAudioDecoder != NULL) { 1293 flushDecoder(true /* audio */, true /* needShutdown */); 1294 } 1295 1296 if (video && mVideoDecoder != NULL) { 1297 flushDecoder(false /* audio */, true /* needShutdown */); 1298 } 1299} 1300 1301void NuPlayer::performReset() { 1302 ALOGV("performReset"); 1303 1304 CHECK(mAudioDecoder == NULL); 1305 CHECK(mVideoDecoder == NULL); 1306 1307 cancelPollDuration(); 1308 1309 ++mScanSourcesGeneration; 1310 mScanSourcesPending = false; 1311 1312 mRenderer.clear(); 1313 1314 if (mSource != NULL) { 1315 mSource->stop(); 1316 1317 looper()->unregisterHandler(mSource->id()); 1318 1319 mSource.clear(); 1320 } 1321 1322 if (mDriver != NULL) { 1323 sp<NuPlayerDriver> driver = mDriver.promote(); 1324 if (driver != NULL) { 1325 driver->notifyResetComplete(); 1326 } 1327 } 1328 1329 mStarted = false; 1330} 1331 1332void NuPlayer::performScanSources() { 1333 ALOGV("performScanSources"); 1334 1335 if (!mStarted) { 1336 return; 1337 } 1338 1339 if (mAudioDecoder == NULL || mVideoDecoder == NULL) { 1340 postScanSources(); 1341 } 1342} 1343 1344void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) { 1345 ALOGV("performSetSurface"); 1346 1347 mNativeWindow = wrapper; 1348 1349 // XXX - ignore error from setVideoScalingMode for now 1350 setVideoScalingMode(mVideoScalingMode); 1351 1352 if (mDriver != NULL) { 1353 sp<NuPlayerDriver> driver = mDriver.promote(); 1354 if (driver != NULL) { 1355 driver->notifySetSurfaceComplete(); 1356 } 1357 } 1358} 1359 1360void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { 1361 int32_t what; 1362 CHECK(msg->findInt32("what", &what)); 1363 1364 switch (what) { 1365 case Source::kWhatPrepared: 1366 { 1367 if (mSource == NULL) { 1368 // This is a stale notification from a source that was 1369 // asynchronously preparing when the client called reset(). 1370 // We handled the reset, the source is gone. 1371 break; 1372 } 1373 1374 int32_t err; 1375 CHECK(msg->findInt32("err", &err)); 1376 1377 sp<NuPlayerDriver> driver = mDriver.promote(); 1378 if (driver != NULL) { 1379 driver->notifyPrepareCompleted(err); 1380 } 1381 1382 int64_t durationUs; 1383 if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) { 1384 sp<NuPlayerDriver> driver = mDriver.promote(); 1385 if (driver != NULL) { 1386 driver->notifyDuration(durationUs); 1387 } 1388 } 1389 break; 1390 } 1391 1392 case Source::kWhatFlagsChanged: 1393 { 1394 uint32_t flags; 1395 CHECK(msg->findInt32("flags", (int32_t *)&flags)); 1396 1397 sp<NuPlayerDriver> driver = mDriver.promote(); 1398 if (driver != NULL) { 1399 driver->notifyFlagsChanged(flags); 1400 } 1401 1402 if ((mSourceFlags & Source::FLAG_DYNAMIC_DURATION) 1403 && (!(flags & Source::FLAG_DYNAMIC_DURATION))) { 1404 cancelPollDuration(); 1405 } else if (!(mSourceFlags & Source::FLAG_DYNAMIC_DURATION) 1406 && (flags & Source::FLAG_DYNAMIC_DURATION) 1407 && (mAudioDecoder != NULL || mVideoDecoder != NULL)) { 1408 schedulePollDuration(); 1409 } 1410 1411 mSourceFlags = flags; 1412 break; 1413 } 1414 1415 case Source::kWhatVideoSizeChanged: 1416 { 1417 int32_t width, height; 1418 CHECK(msg->findInt32("width", &width)); 1419 CHECK(msg->findInt32("height", &height)); 1420 1421 notifyListener(MEDIA_SET_VIDEO_SIZE, width, height); 1422 break; 1423 } 1424 1425 case Source::kWhatBufferingStart: 1426 { 1427 notifyListener(MEDIA_INFO, MEDIA_INFO_BUFFERING_START, 0); 1428 break; 1429 } 1430 1431 case Source::kWhatBufferingEnd: 1432 { 1433 notifyListener(MEDIA_INFO, MEDIA_INFO_BUFFERING_END, 0); 1434 break; 1435 } 1436 1437 case Source::kWhatSubtitleData: 1438 { 1439 sp<ABuffer> buffer; 1440 CHECK(msg->findBuffer("buffer", &buffer)); 1441 1442 int32_t trackIndex; 1443 int64_t timeUs, durationUs; 1444 CHECK(buffer->meta()->findInt32("trackIndex", &trackIndex)); 1445 CHECK(buffer->meta()->findInt64("timeUs", &timeUs)); 1446 CHECK(buffer->meta()->findInt64("durationUs", &durationUs)); 1447 1448 Parcel in; 1449 in.writeInt32(trackIndex); 1450 in.writeInt64(timeUs); 1451 in.writeInt64(durationUs); 1452 in.writeInt32(buffer->size()); 1453 in.writeInt32(buffer->size()); 1454 in.write(buffer->data(), buffer->size()); 1455 1456 notifyListener(MEDIA_SUBTITLE_DATA, 0, 0, &in); 1457 break; 1458 } 1459 1460 case Source::kWhatQueueDecoderShutdown: 1461 { 1462 int32_t audio, video; 1463 CHECK(msg->findInt32("audio", &audio)); 1464 CHECK(msg->findInt32("video", &video)); 1465 1466 sp<AMessage> reply; 1467 CHECK(msg->findMessage("reply", &reply)); 1468 1469 queueDecoderShutdown(audio, video, reply); 1470 break; 1471 } 1472 1473 default: 1474 TRESPASS(); 1475 } 1476} 1477 1478//////////////////////////////////////////////////////////////////////////////// 1479 1480void NuPlayer::Source::notifyFlagsChanged(uint32_t flags) { 1481 sp<AMessage> notify = dupNotify(); 1482 notify->setInt32("what", kWhatFlagsChanged); 1483 notify->setInt32("flags", flags); 1484 notify->post(); 1485} 1486 1487void NuPlayer::Source::notifyVideoSizeChanged(int32_t width, int32_t height) { 1488 sp<AMessage> notify = dupNotify(); 1489 notify->setInt32("what", kWhatVideoSizeChanged); 1490 notify->setInt32("width", width); 1491 notify->setInt32("height", height); 1492 notify->post(); 1493} 1494 1495void NuPlayer::Source::notifyPrepared(status_t err) { 1496 sp<AMessage> notify = dupNotify(); 1497 notify->setInt32("what", kWhatPrepared); 1498 notify->setInt32("err", err); 1499 notify->post(); 1500} 1501 1502void NuPlayer::Source::onMessageReceived(const sp<AMessage> & /* msg */) { 1503 TRESPASS(); 1504} 1505 1506void NuPlayer::queueDecoderShutdown( 1507 bool audio, bool video, const sp<AMessage> &reply) { 1508 ALOGI("queueDecoderShutdown audio=%d, video=%d", audio, video); 1509 1510 mDeferredActions.push_back( 1511 new ShutdownDecoderAction(audio, video)); 1512 1513 mDeferredActions.push_back( 1514 new SimpleAction(&NuPlayer::performScanSources)); 1515 1516 mDeferredActions.push_back(new PostMessageAction(reply)); 1517 1518 processDeferredActions(); 1519} 1520 1521} // namespace android 1522