ATSParser.cpp revision e332a9181cf6a3155ed1a0fd2afc212ccb1f2753
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 "ATSParser" 19#include <utils/Log.h> 20 21#include "ATSParser.h" 22 23#include "AnotherPacketSource.h" 24#include "ESQueue.h" 25#include "include/avc_utils.h" 26 27#include <media/stagefright/foundation/ABitReader.h> 28#include <media/stagefright/foundation/ABuffer.h> 29#include <media/stagefright/foundation/ADebug.h> 30#include <media/stagefright/foundation/AMessage.h> 31#include <media/stagefright/foundation/hexdump.h> 32#include <media/stagefright/MediaDefs.h> 33#include <media/stagefright/MediaErrors.h> 34#include <media/stagefright/MetaData.h> 35#include <utils/KeyedVector.h> 36 37namespace android { 38 39// I want the expression "y" evaluated even if verbose logging is off. 40#define MY_LOGV(x, y) \ 41 do { unsigned tmp = y; LOGV(x, tmp); } while (0) 42 43static const size_t kTSPacketSize = 188; 44 45struct ATSParser::Program : public RefBase { 46 Program(unsigned programMapPID); 47 48 bool parsePID( 49 unsigned pid, unsigned payload_unit_start_indicator, 50 ABitReader *br); 51 52 void signalDiscontinuity(bool isASeek); 53 54 sp<MediaSource> getSource(SourceType type); 55 56 int64_t convertPTSToTimestamp(uint64_t PTS); 57 58private: 59 unsigned mProgramMapPID; 60 KeyedVector<unsigned, sp<Stream> > mStreams; 61 bool mFirstPTSValid; 62 uint64_t mFirstPTS; 63 64 void parseProgramMap(ABitReader *br); 65 66 DISALLOW_EVIL_CONSTRUCTORS(Program); 67}; 68 69struct ATSParser::Stream : public RefBase { 70 Stream(Program *program, unsigned elementaryPID, unsigned streamType); 71 72 void parse( 73 unsigned payload_unit_start_indicator, 74 ABitReader *br); 75 76 void signalDiscontinuity(bool isASeek); 77 78 sp<MediaSource> getSource(SourceType type); 79 80protected: 81 virtual ~Stream(); 82 83private: 84 Program *mProgram; 85 unsigned mElementaryPID; 86 unsigned mStreamType; 87 88 sp<ABuffer> mBuffer; 89 sp<AnotherPacketSource> mSource; 90 bool mPayloadStarted; 91 92 ElementaryStreamQueue mQueue; 93 94 void flush(); 95 void parsePES(ABitReader *br); 96 97 void onPayloadData( 98 unsigned PTS_DTS_flags, uint64_t PTS, uint64_t DTS, 99 const uint8_t *data, size_t size); 100 101 void extractAACFrames(const sp<ABuffer> &buffer); 102 103 DISALLOW_EVIL_CONSTRUCTORS(Stream); 104}; 105 106//////////////////////////////////////////////////////////////////////////////// 107 108ATSParser::Program::Program(unsigned programMapPID) 109 : mProgramMapPID(programMapPID), 110 mFirstPTSValid(false), 111 mFirstPTS(0) { 112} 113 114bool ATSParser::Program::parsePID( 115 unsigned pid, unsigned payload_unit_start_indicator, 116 ABitReader *br) { 117 if (pid == mProgramMapPID) { 118 if (payload_unit_start_indicator) { 119 unsigned skip = br->getBits(8); 120 br->skipBits(skip * 8); 121 } 122 123 parseProgramMap(br); 124 return true; 125 } 126 127 ssize_t index = mStreams.indexOfKey(pid); 128 if (index < 0) { 129 return false; 130 } 131 132 mStreams.editValueAt(index)->parse( 133 payload_unit_start_indicator, br); 134 135 return true; 136} 137 138void ATSParser::Program::signalDiscontinuity(bool isASeek) { 139 for (size_t i = 0; i < mStreams.size(); ++i) { 140 mStreams.editValueAt(i)->signalDiscontinuity(isASeek); 141 } 142} 143 144void ATSParser::Program::parseProgramMap(ABitReader *br) { 145 unsigned table_id = br->getBits(8); 146 LOGV(" table_id = %u", table_id); 147 CHECK_EQ(table_id, 0x02u); 148 149 unsigned section_syntax_indicator = br->getBits(1); 150 LOGV(" section_syntax_indicator = %u", section_syntax_indicator); 151 CHECK_EQ(section_syntax_indicator, 1u); 152 153 CHECK_EQ(br->getBits(1), 0u); 154 MY_LOGV(" reserved = %u", br->getBits(2)); 155 156 unsigned section_length = br->getBits(12); 157 LOGV(" section_length = %u", section_length); 158 CHECK((section_length & 0xc00) == 0); 159 CHECK_LE(section_length, 1021u); 160 161 MY_LOGV(" program_number = %u", br->getBits(16)); 162 MY_LOGV(" reserved = %u", br->getBits(2)); 163 MY_LOGV(" version_number = %u", br->getBits(5)); 164 MY_LOGV(" current_next_indicator = %u", br->getBits(1)); 165 MY_LOGV(" section_number = %u", br->getBits(8)); 166 MY_LOGV(" last_section_number = %u", br->getBits(8)); 167 MY_LOGV(" reserved = %u", br->getBits(3)); 168 MY_LOGV(" PCR_PID = 0x%04x", br->getBits(13)); 169 MY_LOGV(" reserved = %u", br->getBits(4)); 170 171 unsigned program_info_length = br->getBits(12); 172 LOGV(" program_info_length = %u", program_info_length); 173 CHECK((program_info_length & 0xc00) == 0); 174 175 br->skipBits(program_info_length * 8); // skip descriptors 176 177 // infoBytesRemaining is the number of bytes that make up the 178 // variable length section of ES_infos. It does not include the 179 // final CRC. 180 size_t infoBytesRemaining = section_length - 9 - program_info_length - 4; 181 182 while (infoBytesRemaining > 0) { 183 CHECK_GE(infoBytesRemaining, 5u); 184 185 unsigned streamType = br->getBits(8); 186 LOGV(" stream_type = 0x%02x", streamType); 187 188 MY_LOGV(" reserved = %u", br->getBits(3)); 189 190 unsigned elementaryPID = br->getBits(13); 191 LOGV(" elementary_PID = 0x%04x", elementaryPID); 192 193 MY_LOGV(" reserved = %u", br->getBits(4)); 194 195 unsigned ES_info_length = br->getBits(12); 196 LOGV(" ES_info_length = %u", ES_info_length); 197 CHECK((ES_info_length & 0xc00) == 0); 198 199 CHECK_GE(infoBytesRemaining - 5, ES_info_length); 200 201#if 0 202 br->skipBits(ES_info_length * 8); // skip descriptors 203#else 204 unsigned info_bytes_remaining = ES_info_length; 205 while (info_bytes_remaining >= 2) { 206 MY_LOGV(" tag = 0x%02x", br->getBits(8)); 207 208 unsigned descLength = br->getBits(8); 209 LOGV(" len = %u", descLength); 210 211 CHECK_GE(info_bytes_remaining, 2 + descLength); 212 213 br->skipBits(descLength * 8); 214 215 info_bytes_remaining -= descLength + 2; 216 } 217 CHECK_EQ(info_bytes_remaining, 0u); 218#endif 219 220 ssize_t index = mStreams.indexOfKey(elementaryPID); 221#if 0 // XXX revisit 222 CHECK_LT(index, 0); 223 mStreams.add(elementaryPID, 224 new Stream(this, elementaryPID, streamType)); 225#else 226 if (index < 0) { 227 mStreams.add(elementaryPID, 228 new Stream(this, elementaryPID, streamType)); 229 } 230#endif 231 232 infoBytesRemaining -= 5 + ES_info_length; 233 } 234 235 CHECK_EQ(infoBytesRemaining, 0u); 236 237 MY_LOGV(" CRC = 0x%08x", br->getBits(32)); 238} 239 240sp<MediaSource> ATSParser::Program::getSource(SourceType type) { 241 for (size_t i = 0; i < mStreams.size(); ++i) { 242 sp<MediaSource> source = mStreams.editValueAt(i)->getSource(type); 243 if (source != NULL) { 244 return source; 245 } 246 } 247 248 return NULL; 249} 250 251int64_t ATSParser::Program::convertPTSToTimestamp(uint64_t PTS) { 252 if (!mFirstPTSValid) { 253 mFirstPTSValid = true; 254 mFirstPTS = PTS; 255 PTS = 0; 256 } else if (PTS < mFirstPTS) { 257 PTS = 0; 258 } else { 259 PTS -= mFirstPTS; 260 } 261 262 return (PTS * 100) / 9; 263} 264 265//////////////////////////////////////////////////////////////////////////////// 266 267ATSParser::Stream::Stream( 268 Program *program, unsigned elementaryPID, unsigned streamType) 269 : mProgram(program), 270 mElementaryPID(elementaryPID), 271 mStreamType(streamType), 272 mBuffer(new ABuffer(128 * 1024)), 273 mPayloadStarted(false), 274 mQueue(streamType == 0x1b 275 ? ElementaryStreamQueue::H264 : ElementaryStreamQueue::AAC) { 276 mBuffer->setRange(0, 0); 277 278 LOGV("new stream PID 0x%02x, type 0x%02x", elementaryPID, streamType); 279} 280 281ATSParser::Stream::~Stream() { 282} 283 284void ATSParser::Stream::parse( 285 unsigned payload_unit_start_indicator, ABitReader *br) { 286 if (payload_unit_start_indicator) { 287 if (mPayloadStarted) { 288 // Otherwise we run the danger of receiving the trailing bytes 289 // of a PES packet that we never saw the start of and assuming 290 // we have a a complete PES packet. 291 292 flush(); 293 } 294 295 mPayloadStarted = true; 296 } 297 298 if (!mPayloadStarted) { 299 return; 300 } 301 302 size_t payloadSizeBits = br->numBitsLeft(); 303 CHECK((payloadSizeBits % 8) == 0); 304 305 CHECK_LE(mBuffer->size() + payloadSizeBits / 8, mBuffer->capacity()); 306 307 memcpy(mBuffer->data() + mBuffer->size(), br->data(), payloadSizeBits / 8); 308 mBuffer->setRange(0, mBuffer->size() + payloadSizeBits / 8); 309} 310 311void ATSParser::Stream::signalDiscontinuity(bool isASeek) { 312 isASeek = false; // Always signal a "real" discontinuity 313 314 mPayloadStarted = false; 315 mBuffer->setRange(0, 0); 316 317 mQueue.clear(); 318 319 if (isASeek) { 320 // This is only a "minor" discontinuity, we stay within the same 321 // bitstream. 322 323 if (mSource != NULL) { 324 mSource->clear(); 325 } 326 return; 327 } 328 329 if (mStreamType == 0x1b && mSource != NULL) { 330 // Don't signal discontinuities on audio streams. 331 mSource->queueDiscontinuity(); 332 } 333} 334 335void ATSParser::Stream::parsePES(ABitReader *br) { 336 unsigned packet_startcode_prefix = br->getBits(24); 337 338 LOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix); 339 340 CHECK_EQ(packet_startcode_prefix, 0x000001u); 341 342 unsigned stream_id = br->getBits(8); 343 LOGV("stream_id = 0x%02x", stream_id); 344 345 unsigned PES_packet_length = br->getBits(16); 346 LOGV("PES_packet_length = %u", PES_packet_length); 347 348 if (stream_id != 0xbc // program_stream_map 349 && stream_id != 0xbe // padding_stream 350 && stream_id != 0xbf // private_stream_2 351 && stream_id != 0xf0 // ECM 352 && stream_id != 0xf1 // EMM 353 && stream_id != 0xff // program_stream_directory 354 && stream_id != 0xf2 // DSMCC 355 && stream_id != 0xf8) { // H.222.1 type E 356 CHECK_EQ(br->getBits(2), 2u); 357 358 MY_LOGV("PES_scrambling_control = %u", br->getBits(2)); 359 MY_LOGV("PES_priority = %u", br->getBits(1)); 360 MY_LOGV("data_alignment_indicator = %u", br->getBits(1)); 361 MY_LOGV("copyright = %u", br->getBits(1)); 362 MY_LOGV("original_or_copy = %u", br->getBits(1)); 363 364 unsigned PTS_DTS_flags = br->getBits(2); 365 LOGV("PTS_DTS_flags = %u", PTS_DTS_flags); 366 367 unsigned ESCR_flag = br->getBits(1); 368 LOGV("ESCR_flag = %u", ESCR_flag); 369 370 unsigned ES_rate_flag = br->getBits(1); 371 LOGV("ES_rate_flag = %u", ES_rate_flag); 372 373 unsigned DSM_trick_mode_flag = br->getBits(1); 374 LOGV("DSM_trick_mode_flag = %u", DSM_trick_mode_flag); 375 376 unsigned additional_copy_info_flag = br->getBits(1); 377 LOGV("additional_copy_info_flag = %u", additional_copy_info_flag); 378 379 MY_LOGV("PES_CRC_flag = %u", br->getBits(1)); 380 MY_LOGV("PES_extension_flag = %u", br->getBits(1)); 381 382 unsigned PES_header_data_length = br->getBits(8); 383 LOGV("PES_header_data_length = %u", PES_header_data_length); 384 385 unsigned optional_bytes_remaining = PES_header_data_length; 386 387 uint64_t PTS = 0, DTS = 0; 388 389 if (PTS_DTS_flags == 2 || PTS_DTS_flags == 3) { 390 CHECK_GE(optional_bytes_remaining, 5u); 391 392 CHECK_EQ(br->getBits(4), PTS_DTS_flags); 393 394 PTS = ((uint64_t)br->getBits(3)) << 30; 395 CHECK_EQ(br->getBits(1), 1u); 396 PTS |= ((uint64_t)br->getBits(15)) << 15; 397 CHECK_EQ(br->getBits(1), 1u); 398 PTS |= br->getBits(15); 399 CHECK_EQ(br->getBits(1), 1u); 400 401 LOGV("PTS = %llu", PTS); 402 // LOGI("PTS = %.2f secs", PTS / 90000.0f); 403 404 optional_bytes_remaining -= 5; 405 406 if (PTS_DTS_flags == 3) { 407 CHECK_GE(optional_bytes_remaining, 5u); 408 409 CHECK_EQ(br->getBits(4), 1u); 410 411 DTS = ((uint64_t)br->getBits(3)) << 30; 412 CHECK_EQ(br->getBits(1), 1u); 413 DTS |= ((uint64_t)br->getBits(15)) << 15; 414 CHECK_EQ(br->getBits(1), 1u); 415 DTS |= br->getBits(15); 416 CHECK_EQ(br->getBits(1), 1u); 417 418 LOGV("DTS = %llu", DTS); 419 420 optional_bytes_remaining -= 5; 421 } 422 } 423 424 if (ESCR_flag) { 425 CHECK_GE(optional_bytes_remaining, 6u); 426 427 br->getBits(2); 428 429 uint64_t ESCR = ((uint64_t)br->getBits(3)) << 30; 430 CHECK_EQ(br->getBits(1), 1u); 431 ESCR |= ((uint64_t)br->getBits(15)) << 15; 432 CHECK_EQ(br->getBits(1), 1u); 433 ESCR |= br->getBits(15); 434 CHECK_EQ(br->getBits(1), 1u); 435 436 LOGV("ESCR = %llu", ESCR); 437 MY_LOGV("ESCR_extension = %u", br->getBits(9)); 438 439 CHECK_EQ(br->getBits(1), 1u); 440 441 optional_bytes_remaining -= 6; 442 } 443 444 if (ES_rate_flag) { 445 CHECK_GE(optional_bytes_remaining, 3u); 446 447 CHECK_EQ(br->getBits(1), 1u); 448 MY_LOGV("ES_rate = %u", br->getBits(22)); 449 CHECK_EQ(br->getBits(1), 1u); 450 451 optional_bytes_remaining -= 3; 452 } 453 454 br->skipBits(optional_bytes_remaining * 8); 455 456 // ES data follows. 457 458 if (PES_packet_length != 0) { 459 CHECK_GE(PES_packet_length, PES_header_data_length + 3); 460 461 unsigned dataLength = 462 PES_packet_length - 3 - PES_header_data_length; 463 464 CHECK_GE(br->numBitsLeft(), dataLength * 8); 465 466 onPayloadData( 467 PTS_DTS_flags, PTS, DTS, br->data(), dataLength); 468 469 br->skipBits(dataLength * 8); 470 } else { 471 onPayloadData( 472 PTS_DTS_flags, PTS, DTS, 473 br->data(), br->numBitsLeft() / 8); 474 475 size_t payloadSizeBits = br->numBitsLeft(); 476 CHECK((payloadSizeBits % 8) == 0); 477 478 LOGV("There's %d bytes of payload.", payloadSizeBits / 8); 479 } 480 } else if (stream_id == 0xbe) { // padding_stream 481 CHECK_NE(PES_packet_length, 0u); 482 br->skipBits(PES_packet_length * 8); 483 } else { 484 CHECK_NE(PES_packet_length, 0u); 485 br->skipBits(PES_packet_length * 8); 486 } 487} 488 489void ATSParser::Stream::flush() { 490 if (mBuffer->size() == 0) { 491 return; 492 } 493 494 LOGV("flushing stream 0x%04x size = %d", mElementaryPID, mBuffer->size()); 495 496 ABitReader br(mBuffer->data(), mBuffer->size()); 497 parsePES(&br); 498 499 mBuffer->setRange(0, 0); 500} 501 502void ATSParser::Stream::onPayloadData( 503 unsigned PTS_DTS_flags, uint64_t PTS, uint64_t DTS, 504 const uint8_t *data, size_t size) { 505 LOGV("onPayloadData mStreamType=0x%02x", mStreamType); 506 507 CHECK(PTS_DTS_flags == 2 || PTS_DTS_flags == 3); 508 int64_t timeUs = mProgram->convertPTSToTimestamp(PTS); 509 510 status_t err = mQueue.appendData(data, size, timeUs); 511 CHECK_EQ(err, (status_t)OK); 512 513 sp<ABuffer> accessUnit; 514 while ((accessUnit = mQueue.dequeueAccessUnit()) != NULL) { 515 if (mSource == NULL) { 516 sp<MetaData> meta = mQueue.getFormat(); 517 518 if (meta != NULL) { 519 LOGV("created source!"); 520 mSource = new AnotherPacketSource(meta); 521 mSource->queueAccessUnit(accessUnit); 522 } 523 } else if (mQueue.getFormat() != NULL) { 524 // After a discontinuity we invalidate the queue's format 525 // and won't enqueue any access units to the source until 526 // the queue has reestablished the new format. 527 mSource->queueAccessUnit(accessUnit); 528 } 529 } 530} 531 532sp<MediaSource> ATSParser::Stream::getSource(SourceType type) { 533 if ((type == AVC_VIDEO && mStreamType == 0x1b) 534 || (type == MPEG2ADTS_AUDIO && mStreamType == 0x0f)) { 535 return mSource; 536 } 537 538 return NULL; 539} 540 541//////////////////////////////////////////////////////////////////////////////// 542 543ATSParser::ATSParser() { 544} 545 546ATSParser::~ATSParser() { 547} 548 549void ATSParser::feedTSPacket(const void *data, size_t size) { 550 CHECK_EQ(size, kTSPacketSize); 551 552 ABitReader br((const uint8_t *)data, kTSPacketSize); 553 parseTS(&br); 554} 555 556void ATSParser::signalDiscontinuity(bool isASeek) { 557 for (size_t i = 0; i < mPrograms.size(); ++i) { 558 mPrograms.editItemAt(i)->signalDiscontinuity(isASeek); 559 } 560} 561 562void ATSParser::parseProgramAssociationTable(ABitReader *br) { 563 unsigned table_id = br->getBits(8); 564 LOGV(" table_id = %u", table_id); 565 CHECK_EQ(table_id, 0x00u); 566 567 unsigned section_syntax_indictor = br->getBits(1); 568 LOGV(" section_syntax_indictor = %u", section_syntax_indictor); 569 CHECK_EQ(section_syntax_indictor, 1u); 570 571 CHECK_EQ(br->getBits(1), 0u); 572 MY_LOGV(" reserved = %u", br->getBits(2)); 573 574 unsigned section_length = br->getBits(12); 575 LOGV(" section_length = %u", section_length); 576 CHECK((section_length & 0xc00) == 0); 577 578 MY_LOGV(" transport_stream_id = %u", br->getBits(16)); 579 MY_LOGV(" reserved = %u", br->getBits(2)); 580 MY_LOGV(" version_number = %u", br->getBits(5)); 581 MY_LOGV(" current_next_indicator = %u", br->getBits(1)); 582 MY_LOGV(" section_number = %u", br->getBits(8)); 583 MY_LOGV(" last_section_number = %u", br->getBits(8)); 584 585 size_t numProgramBytes = (section_length - 5 /* header */ - 4 /* crc */); 586 CHECK_EQ((numProgramBytes % 4), 0u); 587 588 for (size_t i = 0; i < numProgramBytes / 4; ++i) { 589 unsigned program_number = br->getBits(16); 590 LOGV(" program_number = %u", program_number); 591 592 MY_LOGV(" reserved = %u", br->getBits(3)); 593 594 if (program_number == 0) { 595 MY_LOGV(" network_PID = 0x%04x", br->getBits(13)); 596 } else { 597 unsigned programMapPID = br->getBits(13); 598 599 LOGV(" program_map_PID = 0x%04x", programMapPID); 600 601 mPrograms.push(new Program(programMapPID)); 602 } 603 } 604 605 MY_LOGV(" CRC = 0x%08x", br->getBits(32)); 606} 607 608void ATSParser::parsePID( 609 ABitReader *br, unsigned PID, 610 unsigned payload_unit_start_indicator) { 611 if (PID == 0) { 612 if (payload_unit_start_indicator) { 613 unsigned skip = br->getBits(8); 614 br->skipBits(skip * 8); 615 } 616 parseProgramAssociationTable(br); 617 return; 618 } 619 620 bool handled = false; 621 for (size_t i = 0; i < mPrograms.size(); ++i) { 622 if (mPrograms.editItemAt(i)->parsePID( 623 PID, payload_unit_start_indicator, br)) { 624 handled = true; 625 break; 626 } 627 } 628 629 if (!handled) { 630 LOGV("PID 0x%04x not handled.", PID); 631 } 632} 633 634void ATSParser::parseAdaptationField(ABitReader *br) { 635 unsigned adaptation_field_length = br->getBits(8); 636 if (adaptation_field_length > 0) { 637 br->skipBits(adaptation_field_length * 8); // XXX 638 } 639} 640 641void ATSParser::parseTS(ABitReader *br) { 642 LOGV("---"); 643 644 unsigned sync_byte = br->getBits(8); 645 CHECK_EQ(sync_byte, 0x47u); 646 647 MY_LOGV("transport_error_indicator = %u", br->getBits(1)); 648 649 unsigned payload_unit_start_indicator = br->getBits(1); 650 LOGV("payload_unit_start_indicator = %u", payload_unit_start_indicator); 651 652 MY_LOGV("transport_priority = %u", br->getBits(1)); 653 654 unsigned PID = br->getBits(13); 655 LOGV("PID = 0x%04x", PID); 656 657 MY_LOGV("transport_scrambling_control = %u", br->getBits(2)); 658 659 unsigned adaptation_field_control = br->getBits(2); 660 LOGV("adaptation_field_control = %u", adaptation_field_control); 661 662 unsigned continuity_counter = br->getBits(4); 663 LOGV("continuity_counter = %u", continuity_counter); 664 665 // LOGI("PID = 0x%04x, continuity_counter = %u", PID, continuity_counter); 666 667 if (adaptation_field_control == 2 || adaptation_field_control == 3) { 668 parseAdaptationField(br); 669 } 670 671 if (adaptation_field_control == 1 || adaptation_field_control == 3) { 672 parsePID(br, PID, payload_unit_start_indicator); 673 } 674} 675 676sp<MediaSource> ATSParser::getSource(SourceType type) { 677 for (size_t i = 0; i < mPrograms.size(); ++i) { 678 sp<MediaSource> source = mPrograms.editItemAt(i)->getSource(type); 679 680 if (source != NULL) { 681 return source; 682 } 683 } 684 685 return NULL; 686} 687 688} // namespace android 689