/*----------------------------------------------------------------------
|   AP4_HintTrackReader::GetNextPacket
+---------------------------------------------------------------------*/
AP4_Result
AP4_HintTrackReader::GetNextPacket(AP4_DataBuffer& packet_data, 
                                   AP4_UI32&       ts_ms)
{
    AP4_Result result = AP4_SUCCESS;

    // get the next rtp sample if needed
    AP4_List<AP4_RtpPacket>* packets = &m_RtpSampleData->GetPackets();
    while (m_PacketIndex == packets->ItemCount()) { // while: handle the 0 packet case
        result = GetRtpSample(++m_SampleIndex);
        if (AP4_FAILED(result)) return result;
        packets = &m_RtpSampleData->GetPackets();
    }

    // get the packet
    AP4_RtpPacket* packet;
    result = packets->Get(m_PacketIndex++, packet);
    if (AP4_FAILED(result)) return result;

    // build it
    result = BuildRtpPacket(packet, packet_data);
    if (AP4_FAILED(result)) return result;

    // set the time stamp
    ts_ms = GetCurrentTimeStampMs();

    return result;
}