Commit 2f0dee1e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Merge Audio/Video & MediaPlayer

parent 8c74e8db
/*****************************************************************************
* libvlc_Audio.cpp: Audio implementation
*****************************************************************************
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
*
* 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
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* This file is autogenerated */
#include <vlc.hpp>
namespace VLC {
Audio::Audio(libvlc_media_player_t* obj)
{
if (!obj)
{
throw Exception("Can't construct Audio");
}
m_obj = obj;
}
Audio::Audio(const Audio& another)
{
m_obj = another.m_obj;
retain();
}
const Audio& Audio::operator=(const Audio& another)
{
if (this == &another)
{
return *this;
}
release();
m_obj = another.m_obj;
retain();
return *this;
}
bool Audio::operator==(const Audio& another) const
{
return m_obj == another.m_obj;
}
Audio::~Audio()
{
release();
}
void Audio::setCallbacks(libvlc_audio_play_cb play, libvlc_audio_pause_cb pause, libvlc_audio_resume_cb resume, libvlc_audio_flush_cb flush, libvlc_audio_drain_cb drain, void * opaque)
{
libvlc_audio_set_callbacks(m_obj, play, pause, resume, flush, drain, opaque);
}
void Audio::setVolumeCallback(libvlc_audio_set_volume_cb set_volume)
{
libvlc_audio_set_volume_callback(m_obj, set_volume);
}
void Audio::setFormatCallbacks(libvlc_audio_setup_cb setup, libvlc_audio_cleanup_cb cleanup)
{
libvlc_audio_set_format_callbacks(m_obj, setup, cleanup);
}
void Audio::setFormat(const std::string& format, unsigned rate, unsigned channels)
{
libvlc_audio_set_format(m_obj, format.c_str(), rate, channels);
}
int Audio::outputSet(const std::string& psz_name)
{
int c_result = libvlc_audio_output_set(m_obj, psz_name.c_str());
int result = c_result;
return result;
}
libvlc_audio_output_device_t * Audio::outputDeviceEnum()
{
libvlc_audio_output_device_t * c_result = libvlc_audio_output_device_enum(m_obj);
libvlc_audio_output_device_t * result = c_result;
return result;
}
void Audio::outputDeviceSet(const std::string& module, const std::string& device_id)
{
libvlc_audio_output_device_set(m_obj, module.c_str(), device_id.c_str());
}
void Audio::toggleMute()
{
libvlc_audio_toggle_mute(m_obj);
}
int Audio::mute()
{
int c_result = libvlc_audio_get_mute(m_obj);
int result = c_result;
return result;
}
void Audio::setMute(int status)
{
libvlc_audio_set_mute(m_obj, status);
}
int Audio::volume()
{
int c_result = libvlc_audio_get_volume(m_obj);
int result = c_result;
return result;
}
int Audio::setVolume(int i_volume)
{
int c_result = libvlc_audio_set_volume(m_obj, i_volume);
int result = c_result;
return result;
}
int Audio::trackCount()
{
int c_result = libvlc_audio_get_track_count(m_obj);
int result = c_result;
return result;
}
std::list<TrackDescription> Audio::trackDescription()
{
libvlc_track_description_t * c_result = libvlc_audio_get_track_description(m_obj);
std::list<TrackDescription> result = TrackDescription::makeList(c_result);
libvlc_track_description_list_release(c_result);
return result;
}
int Audio::track()
{
int c_result = libvlc_audio_get_track(m_obj);
int result = c_result;
return result;
}
int Audio::setTrack(int i_track)
{
int c_result = libvlc_audio_set_track(m_obj, i_track);
int result = c_result;
return result;
}
int Audio::channel()
{
int c_result = libvlc_audio_get_channel(m_obj);
int result = c_result;
return result;
}
int Audio::setChannel(int channel)
{
int c_result = libvlc_audio_set_channel(m_obj, channel);
int result = c_result;
return result;
}
int64_t Audio::delay()
{
int64_t c_result = libvlc_audio_get_delay(m_obj);
int64_t result = c_result;
return result;
}
int Audio::setDelay(int64_t i_delay)
{
int c_result = libvlc_audio_set_delay(m_obj, i_delay);
int result = c_result;
return result;
}
void Audio::retain() {
libvlc_media_player_retain(m_obj);
}
void Audio::release() {
libvlc_media_player_release(m_obj);
}
} // namespace VLC
/*****************************************************************************
* libvlc_Audio.hpp: Audio API
*****************************************************************************
* Copyright © 2014 the VideoLAN team
*
* Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
*
* 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
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* This file is autogenerated */
#ifndef LIBVLC_CXX_AUDIO_H
#define LIBVLC_CXX_AUDIO_H
#include <libvlc_common.hpp>
#include "libvlcpp.hpp"
namespace VLC
{
class Audio : public Internal<
{
public:
/**
* Copy libvlc_media_player_t from another to new Audio object.
* \param another existing Audio
*/
Audio(const Audio& another);
/**
* Copy libvlc_media_player_t from another Audio
* to this Audio
* \param another existing Audio
*/
const Audio& operator=(const Audio& another);
/**
* Check if 2 Audio objects contain the same libvlc_media_player_t.
* \param another another Audio
* \return true if they contain the same libvlc_media_player_t
*/
bool operator==(const Audio& another) const;
~Audio();
/**
* Set callbacks and private data for decoded audio. Use
* Audio::setFormat() or Audio::setFormatCallbacks() to configure the
* decoded audio format.
*
* \param play callback to play audio samples (must not be NULL)
*
* \param pause callback to pause playback (or NULL to ignore)
*
* \param resume callback to resume playback (or NULL to ignore)
*
* \param flush callback to flush audio buffers (or NULL to ignore)
*
* \param drain callback to drain audio buffers (or NULL to ignore)
*
* \param opaque private pointer for the audio callbacks (as first
* parameter)
*
* \version LibVLC 2.0.0 or later
*/
void setCallbacks(libvlc_audio_play_cb play, libvlc_audio_pause_cb pause, libvlc_audio_resume_cb resume, libvlc_audio_flush_cb flush, libvlc_audio_drain_cb drain, void * opaque);
/**
* Set callbacks and private data for decoded audio. Use
* Audio::setFormat() or Audio::setFormatCallbacks() to configure the
* decoded audio format.
*
* \param set_volume callback to apply audio volume, or NULL to apply
* volume in software
*
* \version LibVLC 2.0.0 or later
*/
void setVolumeCallback(libvlc_audio_set_volume_cb set_volume);
/**
* Set decoded audio format. This only works in combination with
* Audio::setCallbacks() .
*
* \param setup callback to select the audio format (cannot be NULL)
*
* \param cleanup callback to release any allocated resources (or NULL)
*
* \version LibVLC 2.0.0 or later
*/
void setFormatCallbacks(libvlc_audio_setup_cb setup, libvlc_audio_cleanup_cb cleanup);
/**
* Set decoded audio format. This only works in combination with
* Audio::setCallbacks() , and is mutually exclusive with
* Audio::setFormatCallbacks() .
*
* \param format a four-characters string identifying the sample format
* (e.g. "S16N" or "FL32")
*
* \param rate sample rate (expressed in Hz)
*
* \param channels channels count
*
* \version LibVLC 2.0.0 or later
*/
void setFormat(const std::string& format, unsigned rate, unsigned channels);
/**
* Selects an audio output module.
*
* \note Any change will take be effect only after playback is stopped
* and restarted. Audio output cannot be changed while playing.
*
* \param psz_name name of audio output, use psz_name of
*
* \see AudioOutputDescription
*
* \return 0 if function succeded, -1 on error
*/
int outputSet(const std::string& psz_name);
/**
* Gets a list of potential audio output devices,
*
* \see Audio::outputDeviceSet() .
*
* \note Not all audio outputs support enumerating devices. The audio
* output may be functional even if the list is empty (NULL).
*
* \note The list may not be exhaustive.
*
* \warning Some audio output devices in the list might not actually work
* in some circumstances. By default, it is recommended to not specify
* any explicit audio device.
*
* \return A NULL-terminated linked list of potential audio output
* devices. It must be freed it with
* libvlc_audio_output_device_list_release()
*
* \version LibVLC 2.2.0 or later.
*/
libvlc_audio_output_device_t * outputDeviceEnum();
/**
* Configures an explicit audio output device.
*
* If the module paramater is NULL, audio output will be moved to the
* device specified by the device identifier string immediately. This is
* the recommended usage.
*
* A list of adequate potential device strings can be obtained with
* Audio::outputDeviceEnum() .
*
* However passing NULL is supported in LibVLC version 2.2.0 and later
* only; in earlier versions, this function would have no effects when
* the module parameter was NULL.
*
* If the module parameter is not NULL, the device parameter of the
* corresponding audio output, if it exists, will be set to the specified
* string. Note that some audio output modules do not have such a
* parameter (notably MMDevice and PulseAudio).
*
* A list of adequate potential device strings can be obtained with
* Instance::audioOutputDeviceList() .
*
* \note This function does not select the specified audio output plugin.
* Audio::outputSet() is used for that purpose.
*
* \warning The syntax for the device parameter depends on the audio
* output. Some audio output modules require further parameters (e.g. a
* channels map in the case of ALSA).
*
* \param module If NULL, current audio output module. if non-NULL, name
* of audio output module (
*
* \see AudioOutputDescription )
*
* \param device_id device identifier string
*
* \return Nothing. Errors are ignored (this is a design bug).
*/
void outputDeviceSet(const std::string& module, const std::string& device_id);
/**
* Toggle mute status.
*
* \warning Toggling mute atomically is not always possible: On some
* platforms, other processes can mute the VLC audio playback stream
* asynchronously. Thus, there is a small race condition where toggling
* will not work. See also the limitations of Audio::setMute() .
*/
void toggleMute();
/**
* Get current mute status.
*
* \return the mute status (boolean) if defined, -1 if
* undefined/unapplicable
*/
int mute();
/**
* Set mute status.
*
* \param status If status is true then mute, otherwise unmute
*
* \warning This function does not always work. If there are no active
* audio playback stream, the mute status might not be available. If
* digital pass-through (S/PDIF, HDMI...) is in use, muting may be
* unapplicable. Also some audio output plugins do not support muting at
* all.
*
* \note To force silent playback, disable all audio tracks. This is more
* efficient and reliable than mute.
*/
void setMute(int status);
/**
* Get current software audio volume.
*
* \return the software volume in percents (0 = mute, 100 = nominal /
* 0dB)
*/
int volume();
/**
* Set current software audio volume.
*
* \param i_volume the volume in percents (0 = mute, 100 = 0dB)
*
* \return 0 if the volume was set, -1 if it was out of range
*/
int setVolume(int i_volume);
/**
* Get number of available audio tracks.
*
* \return the number of available audio tracks (int), or -1 if
* unavailable
*/
int trackCount();
/**
* Get the description of available audio tracks.
*
* \return list with description of available audio tracks, or NULL
*/
std::list<TrackDescription> trackDescription();
/**
* Get current audio track.
*
* \return the audio track ID or -1 if no active input.
*/
int track();
/**
* Set current audio track.
*
* \param i_track the track ID (i_id field from track description)
*
* \return 0 on success, -1 on error
*/
int setTrack(int i_track);
/**
* Get current audio channel.
*
* \return the audio channel
*
* \see libvlc_audio_output_channel_t
*/
int channel();
/**
* Set current audio channel.
*
* \param channel the audio channel,
*
* \see libvlc_audio_output_channel_t
*
* \return 0 on success, -1 on error
*/
int setChannel(int channel);
/**
* Get current audio delay.
*
* \return the audio delay (microseconds)
*
* \version LibVLC 1.1.1 or later
*/
int64_t delay();
/**
* Set current audio delay. The audio delay will be reset to zero each
* time the media changes.
*
* \param i_delay the audio delay (microseconds)
*
* \return 0 on success, -1 on error
*
* \version LibVLC 1.1.1 or later
*/
int setDelay(int64_t i_delay);
private:
/**
*/
void retain();
/**
*/
void release();
libvlc_media_player_t* m_obj;
};
} // namespace VLC
#endif
......@@ -27,7 +27,6 @@
namespace VLC {
Media::Media(libvlc_media_t* obj)
{
if (!obj)
......
......@@ -84,18 +84,6 @@ MediaPlayer::MediaPlayer(Media & p_md)
}
}
Audio MediaPlayer::audio() {
retain();
return Audio(m_obj);
}
Video MediaPlayer::video() {
retain();
return Video(m_obj);
}
void MediaPlayer::setMedia(Media & p_md)
{
libvlc_media_player_set_media(m_obj, p_md.get_c_object());
......@@ -395,5 +383,405 @@ void MediaPlayer::retain()
libvlc_media_player_retain(m_obj);
}
void MediaPlayer::setCallbacks(libvlc_audio_play_cb play, libvlc_audio_pause_cb pause, libvlc_audio_resume_cb resume, libvlc_audio_flush_cb flush, libvlc_audio_drain_cb drain, void * opaque)
{
libvlc_audio_set_callbacks(m_obj, play, pause, resume, flush, drain, opaque);
}
void MediaPlayer::setVolumeCallback(libvlc_audio_set_volume_cb set_volume)
{
libvlc_audio_set_volume_callback(m_obj, set_volume);
}
void MediaPlayer::setFormatCallbacks(libvlc_audio_setup_cb setup, libvlc_audio_cleanup_cb cleanup)
{
libvlc_audio_set_format_callbacks(m_obj, setup, cleanup);
}
void MediaPlayer::setFormat(const std::string& format, unsigned rate, unsigned channels)
{
libvlc_audio_set_format(m_obj, format.c_str(), rate, channels);
}
int MediaPlayer::outputSet(const std::string& psz_name)
{
int c_result = libvlc_audio_output_set(m_obj, psz_name.c_str());
int result = c_result;
return result;
}
libvlc_audio_output_device_t * MediaPlayer::outputDeviceEnum()
{
libvlc_audio_output_device_t * c_result = libvlc_audio_output_device_enum(m_obj);
libvlc_audio_output_device_t * result = c_result;
return result;
}
void MediaPlayer::outputDeviceSet(const std::string& module, const std::string& device_id)
{
libvlc_audio_output_device_set(m_obj, module.c_str(), device_id.c_str());
}
void MediaPlayer::toggleMute()
{
libvlc_audio_toggle_mute(m_obj);
}
int MediaPlayer::mute()
{
int c_result = libvlc_audio_get_mute(m_obj);
int result = c_result;
return result;
}
void MediaPlayer::setMute(int status)
{
libvlc_audio_set_mute(m_obj, status);
}
int MediaPlayer::volume()
{
int c_result = libvlc_audio_get_volume(m_obj);
int result = c_result;
return result;
}
int MediaPlayer::setVolume(int i_volume)
{
int c_result = libvlc_audio_set_volume(m_obj, i_volume);
int result = c_result;
return result;
}
int MediaPlayer::audioTrackCount()
{
int c_result = libvlc_audio_get_track_count(m_obj);
int result = c_result;
return result;
}
std::list<TrackDescription> MediaPlayer::audioTrackDescription()
{
libvlc_track_description_t * c_result = libvlc_audio_get_track_description(m_obj);
std::list<TrackDescription> result = TrackDescription::makeList(c_result);
libvlc_track_description_list_release(c_result);
return result;
}
int MediaPlayer::videoTrack()
{
int c_result = libvlc_audio_get_track(m_obj);
int result = c_result;
return result;
}
int MediaPlayer::setVideoTrack(int i_track)
{
int c_result = libvlc_audio_set_track(m_obj, i_track);
int result = c_result;
return result;
}
int MediaPlayer::channel()
{
int c_result = libvlc_audio_get_channel(m_obj);
int result = c_result;
return result;
}
int MediaPlayer::setChannel(int channel)
{
int c_result = libvlc_audio_set_channel(m_obj, channel);
int result = c_result;
return result;
}
int64_t MediaPlayer::delay()
{
int64_t c_result = libvlc_audio_get_delay(m_obj);
int64_t result = c_result;
return result;
}
int MediaPlayer::setDelay(int64_t i_delay)
{
int c_result = libvlc_audio_set_delay(m_obj, i_delay);
int result = c_result;
return result;
}
void MediaPlayer::setCallbacks(libvlc_video_lock_cb lock, libvlc_video_unlock_cb unlock, libvlc_video_display_cb display, void * opaque)
{
libvlc_video_set_callbacks(m_obj, lock, unlock, display, opaque);
}
void MediaPlayer::setFormat(const std::string& chroma, unsigned width, unsigned height, unsigned pitch)
{
libvlc_video_set_format(m_obj, chroma.c_str(), width, height, pitch);
}
void MediaPlayer::setFormatCallbacks(libvlc_video_format_cb setup, libvlc_video_cleanup_cb cleanup)
{
libvlc_video_set_format_callbacks(m_obj, setup, cleanup);
}
void MediaPlayer::setKeyInput(unsigned on)
{
libvlc_video_set_key_input(m_obj, on);
}
void MediaPlayer::setMouseInput(unsigned on)
{
libvlc_video_set_mouse_input(m_obj, on);
}
int MediaPlayer::size(unsigned num, unsigned * px, unsigned * py)
{
int c_result = libvlc_video_get_size(m_obj, num, px, py);
int result = c_result;
return result;
}
int MediaPlayer::cursor(unsigned num, int * px, int * py)
{
int c_result = libvlc_video_get_cursor(m_obj, num, px, py);
int result = c_result;
return result;
}
float MediaPlayer::scale()
{
float c_result = libvlc_video_get_scale(m_obj);
float result = c_result;
return result;
}
void MediaPlayer::setScale(float f_factor)
{
libvlc_video_set_scale(m_obj, f_factor);
}
std::string MediaPlayer::aspectRatio()
{
char * c_result = libvlc_video_get_aspect_ratio(m_obj);
std::string result = c_result;
libvlc_free(c_result);
return result;
}