mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-29 16:30:57 +02:00
Merge pull request #6 from TangoCash/master
Merge
Origin commit data
------------------
Branch: master
Commit: 67e073ecb0
Author: TangoCash <eric@loxat.de>
Date: 2017-11-16 (Thu, 16 Nov 2017)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
#include "../libspark/audio_mixer.h"
|
#include "../libspark/audio_mixer.h"
|
||||||
#elif HAVE_ARM_HARDWARE
|
#elif HAVE_ARM_HARDWARE
|
||||||
#include "../libarmbox/audio_lib.h"
|
#include "../libarmbox/audio_lib.h"
|
||||||
#include "../libarmbox/audio_mixer.h"
|
|
||||||
#elif HAVE_AZBOX_HARDWARE
|
#elif HAVE_AZBOX_HARDWARE
|
||||||
#include "../azbox/audio_lib.h"
|
#include "../azbox/audio_lib.h"
|
||||||
#elif HAVE_GENERIC_HARDWARE
|
#elif HAVE_GENERIC_HARDWARE
|
||||||
|
@@ -38,6 +38,7 @@ typedef struct hw_caps
|
|||||||
int display_yres;
|
int display_yres;
|
||||||
int display_can_set_brightness;
|
int display_can_set_brightness;
|
||||||
int display_can_deepstandby;
|
int display_can_deepstandby;
|
||||||
|
int display_has_statusline;
|
||||||
char boxvendor[64];
|
char boxvendor[64];
|
||||||
char boxname[64];
|
char boxname[64];
|
||||||
char boxarch[64];
|
char boxarch[64];
|
||||||
|
@@ -27,26 +27,17 @@ cAudio::cAudio(void *, void *, void *)
|
|||||||
clipfd = -1;
|
clipfd = -1;
|
||||||
mixer_fd = -1;
|
mixer_fd = -1;
|
||||||
|
|
||||||
/*
|
|
||||||
mixerAnalog = mixerHDMI = mixerSPDIF = NULL;
|
|
||||||
volumeAnalog = volumeHDMI = volumeSPDIF = 0;
|
|
||||||
mixersMuted = false
|
|
||||||
*/
|
|
||||||
|
|
||||||
openDevice();
|
openDevice();
|
||||||
Muted = false;
|
Muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cAudio::~cAudio(void)
|
cAudio::~cAudio(void)
|
||||||
{
|
{
|
||||||
//closeMixers();
|
|
||||||
closeDevice();
|
closeDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cAudio::openDevice(void)
|
void cAudio::openDevice(void)
|
||||||
{
|
{
|
||||||
//openMixers();
|
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
||||||
@@ -60,8 +51,6 @@ void cAudio::openDevice(void)
|
|||||||
|
|
||||||
void cAudio::closeDevice(void)
|
void cAudio::closeDevice(void)
|
||||||
{
|
{
|
||||||
//closeMixers();
|
|
||||||
|
|
||||||
if (fd > -1) {
|
if (fd > -1) {
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@@ -424,57 +413,3 @@ void cAudio::setBypassMode(bool disable)
|
|||||||
if (ioctl(fd, AUDIO_SET_BYPASS_MODE, mode) < 0)
|
if (ioctl(fd, AUDIO_SET_BYPASS_MODE, mode) < 0)
|
||||||
lt_info("%s AUDIO_SET_BYPASS_MODE %d: %m\n", __func__, mode);
|
lt_info("%s AUDIO_SET_BYPASS_MODE %d: %m\n", __func__, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void cAudio::openMixers(void)
|
|
||||||
{
|
|
||||||
if (!mixerAnalog)
|
|
||||||
mixerAnalog = new mixerVolume("Analog", "1");
|
|
||||||
if (!mixerHDMI)
|
|
||||||
mixerHDMI = new mixerVolume("HDMI", "1");
|
|
||||||
if (!mixerSPDIF)
|
|
||||||
mixerSPDIF = new mixerVolume("SPDIF", "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
void cAudio::closeMixers(void)
|
|
||||||
{
|
|
||||||
delete mixerAnalog;
|
|
||||||
delete mixerHDMI;
|
|
||||||
delete mixerSPDIF;
|
|
||||||
mixerAnalog = mixerHDMI = mixerSPDIF = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cAudio::setMixerVolume(const char *name, long value, bool remember)
|
|
||||||
{
|
|
||||||
if (!strcmp(name, "Analog")) {
|
|
||||||
mixerAnalog->setVolume(value);
|
|
||||||
if (remember)
|
|
||||||
volumeAnalog = value;
|
|
||||||
}
|
|
||||||
if (!strcmp(name, "HDMI")) {
|
|
||||||
mixerHDMI->setVolume(value);
|
|
||||||
if (remember)
|
|
||||||
volumeHDMI = value;
|
|
||||||
}
|
|
||||||
if (!strcmp(name, "SPDIF")) {
|
|
||||||
mixerSPDIF->setVolume(value);
|
|
||||||
if (remember)
|
|
||||||
volumeSPDIF = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cAudio::muteMixers(bool m)
|
|
||||||
{
|
|
||||||
if (m && !mixersMuted) {
|
|
||||||
mixersMuted = true;
|
|
||||||
setMixerVolume("Analog", 0, false);
|
|
||||||
setMixerVolume("HDMI", 0, false);
|
|
||||||
setMixerVolume("SPDIF", 0, false);
|
|
||||||
} else if (!m && mixersMuted) {
|
|
||||||
mixersMuted = false;
|
|
||||||
setMixerVolume("Analog", volumeAnalog, false);
|
|
||||||
setMixerVolume("HDMI", volumeHDMI, false);
|
|
||||||
setMixerVolume("SPDIF", volumeSPDIF, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@@ -57,10 +57,6 @@ class cAudio
|
|||||||
int do_mute(bool enable, bool remember);
|
int do_mute(bool enable, bool remember);
|
||||||
void setBypassMode(bool disable);
|
void setBypassMode(bool disable);
|
||||||
|
|
||||||
mixerVolume *mixerAnalog, *mixerHDMI, *mixerSPDIF;
|
|
||||||
int volumeAnalog, volumeHDMI, volumeSPDIF;
|
|
||||||
bool mixersMuted;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* construct & destruct */
|
/* construct & destruct */
|
||||||
cAudio(void *, void *, void *);
|
cAudio(void *, void *, void *);
|
||||||
@@ -99,13 +95,6 @@ class cAudio
|
|||||||
void SetSpdifDD(bool enable);
|
void SetSpdifDD(bool enable);
|
||||||
void ScheduleMute(bool On);
|
void ScheduleMute(bool On);
|
||||||
void EnableAnalogOut(bool enable);
|
void EnableAnalogOut(bool enable);
|
||||||
|
|
||||||
#if 0
|
|
||||||
void openMixers(void);
|
|
||||||
void closeMixers(void);
|
|
||||||
void setMixerVolume(const char *name, long value, bool remember = true);
|
|
||||||
void muteMixers(bool m = true);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* audio_mixer.cpp
|
|
||||||
*
|
|
||||||
* (C) 2012 martii
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <audio_mixer.h>
|
|
||||||
|
|
||||||
mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
|
|
||||||
snd_mixer_selem_id_t *sid = NULL;
|
|
||||||
elem = NULL;
|
|
||||||
handle = NULL;
|
|
||||||
min = 0;
|
|
||||||
max = 100;
|
|
||||||
char cardId[10];
|
|
||||||
|
|
||||||
if (!name || !card)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int cx = snd_card_get_index(card);
|
|
||||||
if (cx < 0 || cx > 31)
|
|
||||||
return;
|
|
||||||
snprintf(cardId, sizeof(cardId), "hw:%i", cx);
|
|
||||||
|
|
||||||
if (0 > snd_mixer_open(&handle, 0))
|
|
||||||
return;
|
|
||||||
if (0 > snd_mixer_attach(handle, cardId))
|
|
||||||
return;
|
|
||||||
if (0 > snd_mixer_selem_register(handle, NULL, NULL))
|
|
||||||
return;
|
|
||||||
if (0 > snd_mixer_load(handle))
|
|
||||||
return;
|
|
||||||
snd_mixer_selem_id_alloca(&sid);
|
|
||||||
if (!sid)
|
|
||||||
return;
|
|
||||||
snd_mixer_selem_id_set_index(sid, 0);
|
|
||||||
snd_mixer_selem_id_set_name(sid, name);
|
|
||||||
elem = snd_mixer_find_selem(handle, sid);
|
|
||||||
if (elem) {
|
|
||||||
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
|
|
||||||
setVolume(volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mixerVolume::~mixerVolume()
|
|
||||||
{
|
|
||||||
if (handle)
|
|
||||||
snd_mixer_close(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mixerVolume::setVolume(long volume) {
|
|
||||||
return elem
|
|
||||||
&& (volume > -1)
|
|
||||||
&& (volume < 101)
|
|
||||||
&& !snd_mixer_selem_set_playback_volume_all(elem, min + volume * (max - min)/100);
|
|
||||||
}
|
|
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* audio_mixer.h
|
|
||||||
*
|
|
||||||
* (C) 2012 martii
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __AUDIO_MIXER_H__
|
|
||||||
#define __AUDIO_MIXER_H__
|
|
||||||
#include <alsa/asoundlib.h>
|
|
||||||
|
|
||||||
class mixerVolume
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
long min, max;
|
|
||||||
snd_mixer_t *handle;
|
|
||||||
snd_mixer_elem_t* elem;
|
|
||||||
public:
|
|
||||||
mixerVolume(const char *selem_name, const char *Card, long volume = -1);
|
|
||||||
~mixerVolume(void);
|
|
||||||
bool setVolume(long volume);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* cDemux implementation for SH4 receivers (tested on fulan spark and
|
* cDemux implementation for arm receivers (tested on mutant hd51
|
||||||
* fulan spark7162 hardware)
|
* hardware)
|
||||||
*
|
*
|
||||||
* derived from libtriple/dmx_td.cpp
|
* derived from libtriple/dmx_td.cpp
|
||||||
*
|
*
|
||||||
@@ -20,41 +20,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Theory of operation (or "why is this dmx_source thing so strange and
|
|
||||||
* what is the _open() good for?")
|
|
||||||
*
|
|
||||||
* the sh4 pti driver, driving the /dev/dvb/adapter0/dmxN devices, can
|
|
||||||
* apparently only map one input to on demux device at a time, so e.g.
|
|
||||||
* DMX_SOURCE_FRONT1 -> demux0
|
|
||||||
* DMX_SOURCE_FRONT2 -> demux0
|
|
||||||
* DMX_SOURCE_FRONT1 -> demux1
|
|
||||||
* does not work. The driver makes sure that a one-to-one mapping of
|
|
||||||
* DMX_SOURCE_FRONTn to demuxM is maintained, and it does by e.g changing
|
|
||||||
* the default of
|
|
||||||
* FRONT0 -> demux0
|
|
||||||
* FRONT1 -> demux1
|
|
||||||
* FRONT2 -> demux2
|
|
||||||
* to
|
|
||||||
* FRONT1 -> demux0
|
|
||||||
* FRONT0 -> demux1
|
|
||||||
* FRONT2 -> demux2
|
|
||||||
* if you do a DMX_SET_SOURCE(FRONT1) ioctl on demux0.
|
|
||||||
* This means, it also changes demux1's source on the SET_SOURCE ioctl on
|
|
||||||
* demux0, potentially disturbing any operation on demux1 (e.g. recording).
|
|
||||||
*
|
|
||||||
* In order to avoid this, I do not change the source->demuxdev mapping
|
|
||||||
* but instead just always use the demux device that is attached to the
|
|
||||||
* correct source.
|
|
||||||
*
|
|
||||||
* The tricky part is, that the source might actually be changed after
|
|
||||||
* Open() has been called, so Open() gets a dummy placeholder that just
|
|
||||||
* sets some variables while the real device open is put into _open().
|
|
||||||
* _open() gets called later, whenever the device is actually used or
|
|
||||||
* configured and -- if the source has changed -- closes the old and
|
|
||||||
* opens the correct new device node.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@@ -72,6 +72,8 @@ GstElement * audioSink = NULL;
|
|||||||
GstElement * videoSink = NULL;
|
GstElement * videoSink = NULL;
|
||||||
gchar * uri = NULL;
|
gchar * uri = NULL;
|
||||||
GstTagList * m_stream_tags = NULL;
|
GstTagList * m_stream_tags = NULL;
|
||||||
|
pthread_mutex_t mutex_tag_ist;
|
||||||
|
|
||||||
static int end_eof = 0;
|
static int end_eof = 0;
|
||||||
#define HTTP_TIMEOUT 30
|
#define HTTP_TIMEOUT 30
|
||||||
// taken from record.h
|
// taken from record.h
|
||||||
@@ -188,8 +190,6 @@ void playbinNotifySource(GObject *object, GParamSpec *param_spec, gpointer user_
|
|||||||
|
|
||||||
GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
||||||
{
|
{
|
||||||
gchar * sourceName;
|
|
||||||
|
|
||||||
// source
|
// source
|
||||||
GstObject * source;
|
GstObject * source;
|
||||||
source = GST_MESSAGE_SRC(msg);
|
source = GST_MESSAGE_SRC(msg);
|
||||||
@@ -197,8 +197,6 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
if (!GST_IS_OBJECT(source))
|
if (!GST_IS_OBJECT(source))
|
||||||
return GST_BUS_DROP;
|
return GST_BUS_DROP;
|
||||||
|
|
||||||
sourceName = gst_object_get_name(source);
|
|
||||||
|
|
||||||
switch (GST_MESSAGE_TYPE(msg))
|
switch (GST_MESSAGE_TYPE(msg))
|
||||||
{
|
{
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
@@ -214,6 +212,7 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
GError *err;
|
GError *err;
|
||||||
gst_message_parse_error(msg, &err, &debug);
|
gst_message_parse_error(msg, &err, &debug);
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
|
gchar * sourceName = gst_object_get_name(source);
|
||||||
lt_info_c( "%s:%s - GST_MESSAGE_ERROR: %s (%i) from %s\n", FILENAME, __FUNCTION__, err->message, err->code, sourceName );
|
lt_info_c( "%s:%s - GST_MESSAGE_ERROR: %s (%i) from %s\n", FILENAME, __FUNCTION__, err->message, err->code, sourceName );
|
||||||
if ( err->domain == GST_STREAM_ERROR )
|
if ( err->domain == GST_STREAM_ERROR )
|
||||||
{
|
{
|
||||||
@@ -226,6 +225,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
|
if(sourceName)
|
||||||
|
g_free(sourceName);
|
||||||
|
|
||||||
end_eof = 1; // NOTE: just to exit
|
end_eof = 1; // NOTE: just to exit
|
||||||
|
|
||||||
@@ -241,8 +242,12 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
g_free (debug);
|
g_free (debug);
|
||||||
if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE )
|
if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE )
|
||||||
{
|
{
|
||||||
|
gchar * sourceName = gst_object_get_name(source);
|
||||||
if ( g_strrstr(sourceName, "videosink") )
|
if ( g_strrstr(sourceName, "videosink") )
|
||||||
lt_info_c( "%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__ ); //FIXME: how shall playback handle this event???
|
lt_info_c( "%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__ ); //FIXME: how shall playback handle this event???
|
||||||
|
if(sourceName)
|
||||||
|
g_free(sourceName);
|
||||||
|
|
||||||
}
|
}
|
||||||
g_error_free(inf);
|
g_error_free(inf);
|
||||||
break;
|
break;
|
||||||
@@ -250,9 +255,16 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
|
|
||||||
case GST_MESSAGE_TAG:
|
case GST_MESSAGE_TAG:
|
||||||
{
|
{
|
||||||
GstTagList *tags, *result;
|
GstTagList *tags = NULL, *result = NULL;
|
||||||
gst_message_parse_tag(msg, &tags);
|
gst_message_parse_tag(msg, &tags);
|
||||||
|
|
||||||
|
if(tags == NULL)
|
||||||
|
break;
|
||||||
|
if(!GST_IS_TAG_LIST(tags))
|
||||||
|
break;
|
||||||
|
|
||||||
|
pthread_mutex_lock (&mutex_tag_ist);
|
||||||
|
|
||||||
result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE);
|
result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@@ -260,6 +272,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
{
|
{
|
||||||
gst_tag_list_unref(tags);
|
gst_tag_list_unref(tags);
|
||||||
gst_tag_list_unref(result);
|
gst_tag_list_unref(result);
|
||||||
|
|
||||||
|
pthread_mutex_unlock (&mutex_tag_ist);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_stream_tags)
|
if (m_stream_tags)
|
||||||
@@ -268,6 +282,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
gst_tag_list_unref(result);
|
gst_tag_list_unref(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock (&mutex_tag_ist);
|
||||||
|
|
||||||
const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0);
|
const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0);
|
||||||
if ( gv_image )
|
if ( gv_image )
|
||||||
{
|
{
|
||||||
@@ -388,8 +404,6 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(sourceName)
|
|
||||||
g_free(sourceName);
|
|
||||||
|
|
||||||
return GST_BUS_DROP;
|
return GST_BUS_DROP;
|
||||||
}
|
}
|
||||||
@@ -405,6 +419,10 @@ cPlayback::cPlayback(int num)
|
|||||||
|
|
||||||
gst_version (&major, &minor, µ, &nano);
|
gst_version (&major, &minor, µ, &nano);
|
||||||
|
|
||||||
|
gst_mpegts_initialize();
|
||||||
|
|
||||||
|
pthread_mutex_init (&mutex_tag_ist, NULL);
|
||||||
|
|
||||||
if (nano == 1)
|
if (nano == 1)
|
||||||
nano_str = "(CVS)";
|
nano_str = "(CVS)";
|
||||||
else if (nano == 2)
|
else if (nano == 2)
|
||||||
@@ -429,8 +447,10 @@ cPlayback::~cPlayback()
|
|||||||
{
|
{
|
||||||
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
||||||
//FIXME: all deleting stuff is done in Close()
|
//FIXME: all deleting stuff is done in Close()
|
||||||
|
pthread_mutex_lock (&mutex_tag_ist);
|
||||||
if (m_stream_tags)
|
if (m_stream_tags)
|
||||||
gst_tag_list_unref(m_stream_tags);
|
gst_tag_list_unref(m_stream_tags);
|
||||||
|
pthread_mutex_unlock (&mutex_tag_ist);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used by Fileplay
|
//Used by Fileplay
|
||||||
@@ -522,9 +542,11 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/,
|
|||||||
mAudioStream = 0;
|
mAudioStream = 0;
|
||||||
init_jump = -1;
|
init_jump = -1;
|
||||||
|
|
||||||
|
pthread_mutex_lock (&mutex_tag_ist);
|
||||||
if (m_stream_tags)
|
if (m_stream_tags)
|
||||||
gst_tag_list_unref(m_stream_tags);
|
gst_tag_list_unref(m_stream_tags);
|
||||||
m_stream_tags = NULL;
|
m_stream_tags = NULL;
|
||||||
|
pthread_mutex_unlock (&mutex_tag_ist);
|
||||||
|
|
||||||
unlink("/tmp/.id3coverart");
|
unlink("/tmp/.id3coverart");
|
||||||
|
|
||||||
@@ -820,7 +842,9 @@ bool cPlayback::GetPosition(int &position, int &duration)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!gst_element_query_position(m_gst_playbin, fmt, &pts))
|
if(!gst_element_query_position(m_gst_playbin, fmt, &pts))
|
||||||
|
{
|
||||||
lt_info( "%s - %d failed\n", __FUNCTION__, __LINE__);
|
lt_info( "%s - %d failed\n", __FUNCTION__, __LINE__);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
position = pts / 1000000.0;
|
position = pts / 1000000.0;
|
||||||
// duration
|
// duration
|
||||||
@@ -843,21 +867,23 @@ bool cPlayback::SetPosition(int position, bool absolute)
|
|||||||
{
|
{
|
||||||
lt_info("%s: pos %d abs %d playing %d\n", __func__, position, absolute, playing);
|
lt_info("%s: pos %d abs %d playing %d\n", __func__, position, absolute, playing);
|
||||||
|
|
||||||
gint64 time_nanoseconds;
|
|
||||||
gint64 pos;
|
|
||||||
GstFormat fmt = GST_FORMAT_TIME;
|
|
||||||
GstState state;
|
|
||||||
|
|
||||||
if(m_gst_playbin)
|
if(m_gst_playbin)
|
||||||
{
|
{
|
||||||
gst_element_get_state(m_gst_playbin, &state, NULL, GST_CLOCK_TIME_NONE);
|
if(first){
|
||||||
|
GstState state;
|
||||||
if ( (state == GST_STATE_PAUSED) && first)
|
gst_element_get_state(m_gst_playbin, &state, NULL, GST_CLOCK_TIME_NONE);
|
||||||
{
|
if ( (state == GST_STATE_PAUSED) && first)
|
||||||
init_jump = position;
|
{
|
||||||
first = false;
|
init_jump = position;
|
||||||
return false;
|
first = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint64 time_nanoseconds;
|
||||||
|
gint64 pos;
|
||||||
|
GstFormat fmt = GST_FORMAT_TIME;
|
||||||
if (!absolute)
|
if (!absolute)
|
||||||
{
|
{
|
||||||
gst_element_query_position(m_gst_playbin, fmt, &pos);
|
gst_element_query_position(m_gst_playbin, fmt, &pos);
|
||||||
@@ -1018,14 +1044,21 @@ void cPlayback::GetMetadata(std::vector<std::string> &keys, std::vector<std::str
|
|||||||
values.clear();
|
values.clear();
|
||||||
|
|
||||||
GstTagList *meta_list = NULL;
|
GstTagList *meta_list = NULL;
|
||||||
if(m_stream_tags)
|
pthread_mutex_lock (&mutex_tag_ist);
|
||||||
|
|
||||||
|
if(m_stream_tags){
|
||||||
meta_list = gst_tag_list_copy(m_stream_tags);
|
meta_list = gst_tag_list_copy(m_stream_tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock (&mutex_tag_ist);
|
||||||
|
|
||||||
if (meta_list == NULL)
|
if (meta_list == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gst_tag_list_is_empty(meta_list))
|
if (gst_tag_list_is_empty(meta_list)){
|
||||||
|
gst_tag_list_unref(meta_list);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (guint i = 0, icnt = gst_tag_list_n_tags(meta_list); i < icnt; i++)
|
for (guint i = 0, icnt = gst_tag_list_n_tags(meta_list); i < icnt; i++)
|
||||||
{
|
{
|
||||||
|
@@ -14,23 +14,7 @@ void cCpuFreqManager::Down(void) { lt_debug("%s\n", __FUNCTION__); }
|
|||||||
void cCpuFreqManager::Reset(void) { lt_debug("%s\n", __FUNCTION__); }
|
void cCpuFreqManager::Reset(void) { lt_debug("%s\n", __FUNCTION__); }
|
||||||
/* those function dummies return true or "harmless" values */
|
/* those function dummies return true or "harmless" values */
|
||||||
bool cCpuFreqManager::SetDelta(unsigned long) { lt_debug("%s\n", __FUNCTION__); return true; }
|
bool cCpuFreqManager::SetDelta(unsigned long) { lt_debug("%s\n", __FUNCTION__); return true; }
|
||||||
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
|
|
||||||
unsigned long cCpuFreqManager::GetCpuFreq(void) {
|
|
||||||
int freq = 0;
|
|
||||||
if (FILE *pll0 = fopen("/proc/cpu_frequ/pll0_ndiv_mdiv", "r")) {
|
|
||||||
char buffer[120];
|
|
||||||
while(fgets(buffer, sizeof(buffer), pll0)) {
|
|
||||||
if (1 == sscanf(buffer, "SH4 = %d MHZ", &freq))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fclose(pll0);
|
|
||||||
return 1000 * 1000 * (unsigned long) freq;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
unsigned long cCpuFreqManager::GetCpuFreq(void) { lt_debug("%s\n", __FUNCTION__); return 0; }
|
unsigned long cCpuFreqManager::GetCpuFreq(void) { lt_debug("%s\n", __FUNCTION__); return 0; }
|
||||||
#endif
|
|
||||||
unsigned long cCpuFreqManager::GetDelta(void) { lt_debug("%s\n", __FUNCTION__); return 0; }
|
unsigned long cCpuFreqManager::GetDelta(void) { lt_debug("%s\n", __FUNCTION__); return 0; }
|
||||||
//
|
//
|
||||||
cCpuFreqManager::cCpuFreqManager(void) { lt_debug("%s\n", __FUNCTION__); }
|
cCpuFreqManager::cCpuFreqManager(void) { lt_debug("%s\n", __FUNCTION__); }
|
||||||
@@ -40,62 +24,8 @@ bool cPowerManager::SetState(PWR_STATE) { lt_debug("%s\n", __FUNCTION__); return
|
|||||||
bool cPowerManager::Open(void) { lt_debug("%s\n", __FUNCTION__); return true; }
|
bool cPowerManager::Open(void) { lt_debug("%s\n", __FUNCTION__); return true; }
|
||||||
void cPowerManager::Close(void) { lt_debug("%s\n", __FUNCTION__); }
|
void cPowerManager::Close(void) { lt_debug("%s\n", __FUNCTION__); }
|
||||||
//
|
//
|
||||||
bool cPowerManager::SetStandby(bool Active, bool Passive)
|
bool cPowerManager::SetStandby(bool Active, bool Passive) { lt_debug("%s(%d, %d)\n", __FUNCTION__, Active, Passive); return true; }
|
||||||
{
|
bool cCpuFreqManager::SetCpuFreq(unsigned long f) { lt_debug("%s(%lu) => set standby = %s\n", __FUNCTION__, f, f?"true":"false"); return true; }
|
||||||
lt_debug("%s(%d, %d)\n", __FUNCTION__, Active, Passive);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cCpuFreqManager::SetCpuFreq(unsigned long f)
|
|
||||||
{
|
|
||||||
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
|
|
||||||
if (f) {
|
|
||||||
FILE *pll0 = fopen ("/proc/cpu_frequ/pll0_ndiv_mdiv", "w");
|
|
||||||
if (pll0) {
|
|
||||||
f /= 1000000;
|
|
||||||
fprintf(pll0, "%lu\n", (f/10 << 8) | 3);
|
|
||||||
fclose (pll0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* actually SetCpuFreq is used to determine if the system is in standby
|
|
||||||
this is an "elegant" hack, because:
|
|
||||||
* during a recording, cpu freq is kept "high", even if the box is sent to standby
|
|
||||||
* the "SetStandby" call is made even if a recording is running
|
|
||||||
On the TD, setting standby disables the frontend, so we must not do it
|
|
||||||
if a recording is running.
|
|
||||||
For now, the values in neutrino are hardcoded:
|
|
||||||
* f == 0 => max => not standby
|
|
||||||
* f == 50000000 => min => standby
|
|
||||||
*/
|
|
||||||
lt_debug("%s(%lu) => set standby = %s\n", __FUNCTION__, f, f?"true":"false");
|
|
||||||
#if 0
|
|
||||||
int fd = open("/dev/stb/tdsystem", O_RDONLY);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
perror("open tdsystem");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (f)
|
|
||||||
{
|
|
||||||
ioctl(fd, IOC_AVS_SET_VOLUME, 31); /* mute AVS to avoid ugly noise */
|
|
||||||
ioctl(fd, IOC_AVS_STANDBY_ENTER);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ioctl(fd, IOC_AVS_SET_VOLUME, 31); /* mute AVS to avoid ugly noise */
|
|
||||||
ioctl(fd, IOC_AVS_STANDBY_LEAVE);
|
|
||||||
/* unmute will be done by cAudio::do_mute(). Ugly, but prevents pops */
|
|
||||||
// ioctl(fd, IOC_AVS_SET_VOLUME, 0); /* max gain */
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
cPowerManager::cPowerManager(void) { lt_debug("%s\n", __FUNCTION__); }
|
cPowerManager::cPowerManager(void) { lt_debug("%s\n", __FUNCTION__); }
|
||||||
cPowerManager::~cPowerManager() { lt_debug("%s\n", __FUNCTION__); }
|
cPowerManager::~cPowerManager() { lt_debug("%s\n", __FUNCTION__); }
|
||||||
|
@@ -40,6 +40,12 @@
|
|||||||
|
|
||||||
#include <proc_tools.h>
|
#include <proc_tools.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
}
|
||||||
|
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
|
||||||
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
|
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
|
||||||
#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args)
|
#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args)
|
||||||
@@ -83,11 +89,6 @@ static const char *VMPEG_yres[] = {
|
|||||||
"/proc/stb/vmpeg/1/yres"
|
"/proc/stb/vmpeg/1/yres"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *VMPEG_dst_all[] = {
|
|
||||||
"/proc/stb/vmpeg/0/dst_all",
|
|
||||||
"/proc/stb/vmpeg/1/dst_all"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *VMPEG_dst_height[] = {
|
static const char *VMPEG_dst_height[] = {
|
||||||
"/proc/stb/vmpeg/0/dst_height",
|
"/proc/stb/vmpeg/0/dst_height",
|
||||||
"/proc/stb/vmpeg/1/dst_height"
|
"/proc/stb/vmpeg/1/dst_height"
|
||||||
@@ -146,6 +147,122 @@ static const char *vid_modes[] = {
|
|||||||
#define VIDEO_STREAMTYPE_H265_HEVC 7
|
#define VIDEO_STREAMTYPE_H265_HEVC 7
|
||||||
#define VIDEO_STREAMTYPE_AVS 16
|
#define VIDEO_STREAMTYPE_AVS 16
|
||||||
|
|
||||||
|
void init_parameters(AVFrame* in_frame, AVCodecContext *codec_context)
|
||||||
|
{
|
||||||
|
/* put sample parameters */
|
||||||
|
codec_context->bit_rate = 400000;
|
||||||
|
/* resolution must be a multiple of two */
|
||||||
|
codec_context->width = (in_frame->width/2)*2;
|
||||||
|
codec_context->height = (in_frame->height/2)*2;
|
||||||
|
/* frames per second */
|
||||||
|
codec_context->time_base = (AVRational ) { 1, 60 };
|
||||||
|
codec_context->gop_size = 10; /* emit one intra frame every ten frames */
|
||||||
|
codec_context->max_b_frames = 1;
|
||||||
|
codec_context->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_frame(AVFrame* in_frame, FILE* fp)
|
||||||
|
{
|
||||||
|
if(in_frame == NULL || fp == NULL)
|
||||||
|
return;
|
||||||
|
AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);
|
||||||
|
if (codec)
|
||||||
|
{
|
||||||
|
AVCodecContext *codec_context = avcodec_alloc_context3(codec);
|
||||||
|
if (codec_context)
|
||||||
|
{
|
||||||
|
init_parameters(in_frame, codec_context);
|
||||||
|
if (avcodec_open2(codec_context, codec, 0) != -1){
|
||||||
|
AVPacket pkt;
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
/* encode the image */
|
||||||
|
int got_output = 0;
|
||||||
|
int ret = avcodec_encode_video2(codec_context, &pkt, in_frame, &got_output);
|
||||||
|
if (ret != -1){
|
||||||
|
if (got_output){
|
||||||
|
fwrite(pkt.data, 1, pkt.size, fp);
|
||||||
|
av_packet_unref(&pkt);
|
||||||
|
}
|
||||||
|
int i =1;
|
||||||
|
for (got_output = 1; got_output; i++){
|
||||||
|
/* get the delayed frames */
|
||||||
|
in_frame->pts = i;
|
||||||
|
ret = avcodec_encode_video2(codec_context, &pkt, 0, &got_output);
|
||||||
|
if (ret != -1 && got_output){
|
||||||
|
fwrite(pkt.data, 1, pkt.size, fp);
|
||||||
|
av_packet_unref(&pkt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
avcodec_close(codec_context);
|
||||||
|
av_free(codec_context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int decode_frame(AVCodecContext *codecContext,AVPacket &packet, FILE* fp)
|
||||||
|
{
|
||||||
|
int decode_ok = 0;
|
||||||
|
AVFrame *frame = av_frame_alloc();
|
||||||
|
if(frame){
|
||||||
|
if ((avcodec_decode_video2(codecContext, frame, &decode_ok, &packet)) < 0 || !decode_ok){
|
||||||
|
av_frame_free(&frame);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
write_frame(frame, fp);
|
||||||
|
av_frame_free(&frame);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCodecContext* open_codec(AVMediaType mediaType, AVFormatContext* formatContext)
|
||||||
|
{
|
||||||
|
int stream_index = av_find_best_stream(formatContext, mediaType, -1, -1, NULL, 0);
|
||||||
|
if (stream_index < 0){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
AVCodecContext * codecContext = formatContext->streams[stream_index]->codec;
|
||||||
|
AVCodec *codec = avcodec_find_decoder(codecContext->codec_id);
|
||||||
|
if (codec && (avcodec_open2(codecContext, codec, NULL)) != 0){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return codecContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
int image_to_mpeg2(const char *image_name, const char *encode_name)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
av_register_all();
|
||||||
|
avcodec_register_all();
|
||||||
|
|
||||||
|
AVFormatContext *formatContext = avformat_alloc_context();
|
||||||
|
if (formatContext && (ret = avformat_open_input(&formatContext, image_name, NULL, NULL)) == 0){
|
||||||
|
AVCodecContext *codecContext = open_codec(AVMEDIA_TYPE_VIDEO, formatContext);
|
||||||
|
if(codecContext){
|
||||||
|
AVPacket packet;
|
||||||
|
av_init_packet(&packet);
|
||||||
|
if ((ret = av_read_frame(formatContext, &packet)) !=-1){
|
||||||
|
FILE* fp = fopen(encode_name, "wb");
|
||||||
|
if(fp){
|
||||||
|
if(decode_frame(codecContext, packet, fp) != 1){
|
||||||
|
/* add sequence end code to have a real mpeg file */
|
||||||
|
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||||
|
fwrite(endcode, 1, sizeof(endcode), fp);
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
avcodec_close(codecContext);
|
||||||
|
av_free_packet(&packet);
|
||||||
|
}
|
||||||
|
avformat_close_input(&formatContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
av_free(formatContext);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
cVideo::cVideo(int, void *, void *, unsigned int unit)
|
cVideo::cVideo(int, void *, void *, unsigned int unit)
|
||||||
{
|
{
|
||||||
lt_debug("%s unit %u\n", __func__, unit);
|
lt_debug("%s unit %u\n", __func__, unit);
|
||||||
@@ -436,7 +553,6 @@ void cVideo::ShowPicture(const char * fname, const char *_destname)
|
|||||||
static const unsigned char pes_header[] = {0x0, 0x0, 0x1, 0xe0, 0x00, 0x00, 0x80, 0x80, 0x5, 0x21, 0x0, 0x1, 0x0, 0x1};
|
static const unsigned char pes_header[] = {0x0, 0x0, 0x1, 0xe0, 0x00, 0x00, 0x80, 0x80, 0x5, 0x21, 0x0, 0x1, 0x0, 0x1};
|
||||||
static const unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 };
|
static const unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 };
|
||||||
char destname[512];
|
char destname[512];
|
||||||
char cmd[512];
|
|
||||||
char *p;
|
char *p;
|
||||||
int mfd;
|
int mfd;
|
||||||
struct stat st, st2;
|
struct stat st, st2;
|
||||||
@@ -477,9 +593,7 @@ void cVideo::ShowPicture(const char * fname, const char *_destname)
|
|||||||
u.actime = time(NULL);
|
u.actime = time(NULL);
|
||||||
u.modtime = st2.st_mtime;
|
u.modtime = st2.st_mtime;
|
||||||
/* it does not exist or has a different date, so call ffmpeg... */
|
/* it does not exist or has a different date, so call ffmpeg... */
|
||||||
sprintf(cmd, "ffmpeg -y -f mjpeg -i '%s' -s 1280x720 -aspect 16:9 '%s' >/dev/null",
|
image_to_mpeg2(fname, destname);
|
||||||
fname, destname);
|
|
||||||
system(cmd); /* TODO: use libavcodec to directly convert it */
|
|
||||||
utime(destname, &u);
|
utime(destname, &u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user