Commit 7fb3156d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Provide a binding for libvlc_media_track_t

parent b545fe45
......@@ -198,11 +198,19 @@ void * Media::userData()
return result;
}
unsigned Media::tracks(libvlc_media_track_t *** tracks)
std::vector<MediaTrack> Media::tracks()
{
unsigned c_result = libvlc_media_tracks_get(m_obj, tracks);
unsigned result = c_result;
return result;
libvlc_media_track_t** tracks;
uint32_t nbTracks = libvlc_media_tracks_get(m_obj, &tracks);
std::vector<MediaTrack> res;
if ( nbTracks == 0 )
return res;
for ( uint32_t i = 0; i < nbTracks; ++i )
res.push_back( MediaTrack(tracks[i]));
libvlc_media_tracks_release( tracks, nbTracks );
return res;
}
Media::Media(Internal::InternalPtr ptr)
......
......@@ -286,7 +286,7 @@ public:
*
* \see Media::meta()
*
* \see Media::tracksInfo()
* \see Media::tracks()
*/
void parseAsync();
......@@ -325,13 +325,9 @@ public:
*
* \version LibVLC 2.1.0 and later.
*
* \param tracks address to store an allocated array of Elementary
* Streams descriptions (must be freed with libvlc_media_tracks_release
* by the caller) [OUT]
*
* \return the number of Elementary Streams (zero on error)
* \return a vector containing all tracks
*/
unsigned tracks(libvlc_media_track_t *** tracks);
std::vector<MediaTrack> tracks();
private:
Media(InternalPtr ptr);
......
......@@ -4,6 +4,7 @@
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -20,11 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* This file is autogenerated */
#include <vlc.hpp>
namespace VLC {
namespace VLC
{
const std::string& ModuleDescription::name() const
{
......@@ -68,62 +68,114 @@ ModuleDescription::ModuleDescription(libvlc_module_description_t* c)
m_help = c->psz_help ? c->psz_help : "";
}
uint32_t MediaTrackInfo::codec() const
uint32_t MediaTrack::codec() const
{
return m_codec;
}
int MediaTrackInfo::id() const
uint32_t MediaTrack::originalFourCC() const
{
return m_originalFourcc;
}
int32_t MediaTrack::id() const
{
return m_id;
}
libvlc_track_type_t MediaTrackInfo::type() const
MediaTrack::Type MediaTrack::type() const
{
return m_type;
}
int MediaTrackInfo::profile() const
uint32_t MediaTrack::height() const
{
return m_profile;
return m_height;
}
int MediaTrackInfo::level() const
uint32_t MediaTrack::width() const
{
return m_level;
return m_width;
}
unsigned MediaTrackInfo::channels() const
uint32_t MediaTrack::sarNum() const
{
return m_channels;
return m_sarNum;
}
unsigned MediaTrackInfo::rate() const
uint32_t MediaTrack::sarDen() const
{
return m_rate;
return m_sarDen;
}
unsigned MediaTrackInfo::height() const
uint32_t MediaTrack::fpsNum() const
{
return m_height;
return m_fpsNum;
}
unsigned MediaTrackInfo::width() const
uint32_t MediaTrack::fpsDen() const
{
return m_width;
return m_fpsDen;
}
MediaTrackInfo::MediaTrackInfo(libvlc_media_track_info_t* c)
const std::string&MediaTrack::encoding() const
{
m_codec = c->i_codec;
m_id = c->i_id;
m_type = c->i_type;
m_profile = c->i_profile;
m_level = c->i_level;
m_channels = c->u.audio.i_channels;
m_rate = c->u.audio.i_rate;
m_height = c->u.video.i_height;
m_width = c->u.video.i_width;
return m_encoding;
}
int32_t MediaTrack::profile() const
{
return m_profile;
}
int32_t MediaTrack::level() const
{
return m_level;
}
uint32_t MediaTrack::channels() const
{
return m_channels;
}
uint32_t MediaTrack::rate() const
{
return m_rate;
}
MediaTrack::MediaTrack( libvlc_media_track_t* c )
: m_codec( c->i_codec )
, m_originalFourcc( c->i_original_fourcc )
, m_id( c->i_id )
, m_profile( c->i_profile )
, m_level( c->i_level )
{
switch ( c->i_type )
{
case libvlc_track_audio:
m_type = Audio;
m_channels = c->audio->i_channels;
m_rate = c->audio->i_rate;
break;
case libvlc_track_video:
m_type = Video;
m_height = c->video->i_height;
m_width = c->video->i_width;
m_sarNum = c->video->i_sar_num;
m_sarDen = c->video->i_sar_den;
m_fpsNum = c->video->i_frame_rate_num;
m_fpsDen = c->video->i_frame_rate_den;
break;
case libvlc_track_text:
m_type = Subtitle;
if ( c->subtitle->psz_encoding != NULL )
m_encoding = c->subtitle->psz_encoding;
break;
case libvlc_track_unknown:
default:
m_type = Unknown;
break;
}
}
const std::string& AudioOutputDescription::name() const
......
......@@ -4,6 +4,7 @@
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
......@@ -20,17 +21,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* This file is autogenerated */
#ifndef LIBVLC_CXX_STRUCTURES_H
#define LIBVLC_CXX_STRUCTURES_H
#include <list>
#include <vector>
namespace VLC {
namespace VLC
{
class Media;
class ModuleDescription
{
......@@ -50,30 +50,59 @@ private:
};
class MediaTrackInfo
class MediaTrack
{
public:
enum Type
{
Unknown = -1,
Audio,
Video,
Subtitle,
};
uint32_t codec() const;
int id() const;
libvlc_track_type_t type() const;
int profile() const;
int level() const;
unsigned channels() const;
unsigned rate() const;
unsigned height() const;
unsigned width() const;
MediaTrackInfo(libvlc_media_track_info_t* c);
uint32_t originalFourCC() const;
int32_t id() const;
Type type() const;
int32_t profile() const;
int32_t level() const;
// Audio specific
uint32_t channels() const;
uint32_t rate() const;
// Video specific
uint32_t height() const;
uint32_t width() const;
uint32_t sarNum() const;
uint32_t sarDen() const;
uint32_t fpsNum() const;
uint32_t fpsDen() const;
// Subtitles specific
const std::string& encoding() const;
private:
MediaTrack(libvlc_media_track_t* c);
uint32_t m_codec;
int m_id;
libvlc_track_type_t m_type;
int m_profile;
int m_level;
unsigned m_channels;
unsigned m_rate;
unsigned m_height;
unsigned m_width;
uint32_t m_originalFourcc;
uint32_t m_id;
Type m_type;
int32_t m_profile;
int32_t m_level;
// Audio
uint32_t m_channels;
uint32_t m_rate;
// Video
uint32_t m_height;
uint32_t m_width;
uint32_t m_sarNum;
uint32_t m_sarDen;
uint32_t m_fpsNum;
uint32_t m_fpsDen;
// Subtitles
std::string m_encoding;
friend class Media;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment