Example #1
0
 AVPacket* Stream::popEncodedData()
 {
     AVPacket* result = nullptr;
     sf::Lock l(m_readerMutex);
     
     if (!m_packetList.size() && !isPassive())
     {
         m_dataSource.requestMoreData(*this);
     }
     
     if (m_packetList.size())
     {
         result = m_packetList.front();
         m_packetList.pop_front();
     }
     else
     {
         if (m_stream->codec->codec->capabilities & CODEC_CAP_DELAY)
         {
             AVPacket* flushPacket = (AVPacket*)av_malloc(sizeof(*flushPacket));
             av_init_packet(flushPacket);
             flushPacket->data = nullptr;
             flushPacket->size = 0;
             result = flushPacket;
             
             sfeLogDebug("Sending flush packet: " + mediaTypeToString(getStreamKind()));
         }
     }
     
     return result;
 }
Example #2
0
void displayMediaInfo(const sfe::Movie& movie)
{
    std::cout << "Status: " << StatusToString(movie.getStatus()) << std::endl;
    std::cout << "Position: " << movie.getPlayingOffset().asSeconds() << "s" << std::endl;
    std::cout << "Duration: " << movie.getDuration().asSeconds() << "s" << std::endl;
    std::cout << "Size: " << movie.getSize().x << "x" << movie.getSize().y << std::endl;
    std::cout << "Framerate: " << movie.getFramerate() << " FPS (average)" << std::endl;
    std::cout << "Volume: " << movie.getVolume() << std::endl;
    std::cout << "Sample rate: " << movie.getSampleRate() << " Hz" << std::endl;
    std::cout << "Channel count: " << movie.getChannelCount() << std::endl;
    
    const sfe::Streams& videoStreams = movie.getStreams(sfe::Video);
    const sfe::Streams& audioStreams = movie.getStreams(sfe::Audio);
    const sfe::Streams& subtitleStreams = movie.getStreams(sfe::Subtitle);
    
    std::cout << videoStreams.size() + audioStreams.size() + subtitleStreams.size() << " streams found in the media" << std::endl;
    
    for (const sfe::StreamDescriptor& descriptor : videoStreams)
        std::cout << " #" << descriptor.identifier << " : " << mediaTypeToString(descriptor.type) << std::endl;
    
    for (const sfe::StreamDescriptor& descriptor : audioStreams)
    {
        std::cout << " #" << descriptor.identifier << " : " << mediaTypeToString(descriptor.type);
        
        if (!descriptor.language.empty())
            std::cout << " (language: " << descriptor.language << ")";
        std::cout << std::endl;
    }
    
    for (const sfe::StreamDescriptor& descriptor : subtitleStreams)
    {
        std::cout << " #" << descriptor.identifier << " : " << mediaTypeToString(descriptor.type);
        
        if (!descriptor.language.empty())
            std::cout << " (language: " << descriptor.language << ")";
        std::cout << std::endl;
    }
}