Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #254 from Jalle19/unify-codec-descriptors
Unify codec descriptor usage
  • Loading branch information
Lars Op den Kamp committed Jan 2, 2014
2 parents 8f46675 + d437bfb commit 0ed916c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 124 deletions.
89 changes: 1 addition & 88 deletions addons/pvr.hts/src/HTSPTypes.h
Expand Up @@ -28,97 +28,10 @@
#include "platform/util/StdString.h"
#include "libXBMC_codec.h"
#include "client.h"

class CodecDescriptor
{
public:
CodecDescriptor(void)
{
m_codec.codec_id = XBMC_INVALID_CODEC_ID;
m_codec.codec_type = XBMC_CODEC_TYPE_UNKNOWN;
}

CodecDescriptor(xbmc_codec_t codec, const char* name) :
m_codec(codec),
m_strName(name) {}
virtual ~CodecDescriptor(void) {}

const std::string& Name(void) const { return m_strName; }
xbmc_codec_t Codec(void) const { return m_codec; }

static CodecDescriptor GetCodecByName(const char* strCodecName)
{
CodecDescriptor retVal;
// some of Tvheadend's and VDR's codec names don't match ffmpeg's, so translate them to something ffmpeg understands
if (!strcmp(strCodecName, "MPEG2AUDIO"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MP2"), strCodecName);
else if (!strcmp(strCodecName, "MPEGTS"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MPEG2VIDEO"), strCodecName);
else
retVal = CodecDescriptor(CODEC->GetCodecByName(strCodecName), strCodecName);

return retVal;
}

private:
xbmc_codec_t m_codec;
std::string m_strName;
};
#include "xbmc_codec_descriptor.hpp"

typedef std::vector<CodecDescriptor> CodecVector;

typedef struct htsmsg htsmsg_t;

template<typename T>
class const_circular_iter :
public std::iterator< typename std::iterator_traits<T>::iterator_category,
typename std::iterator_traits<T>::value_type,
typename std::iterator_traits<T>::difference_type,
typename std::iterator_traits<T>::pointer,
typename std::iterator_traits<T>::reference>
{
protected:
T begin;
T end;
T iter;

public:
typedef typename std::iterator_traits<T>::value_type value_type;
typedef typename std::iterator_traits<T>::difference_type difference_type;
typedef typename std::iterator_traits<T>::pointer pointer;
typedef typename std::iterator_traits<T>::reference reference;

const_circular_iter(const const_circular_iter& src) : begin(src.begin), end(src.end), iter(src.iter) {};
const_circular_iter(const T& b, const T& e) : begin(b), end(e), iter(b) {};
const_circular_iter(const T& b, const T& e, const T& c) : begin(b), end(e), iter(c) {};
const_circular_iter<T>& operator++()
{
if(begin == end)
return(*this);
++iter;
if (iter == end)
iter = begin;
return(*this);
}

const_circular_iter<T>& operator--()
{
if(begin == end)
return(*this);
if (iter == begin)
iter = end;
iter--;
return(*this);
}

reference operator*() const { return (*iter); }
const pointer operator->() const { return &(*iter); }
bool operator==(const const_circular_iter<T>& rhs) const { return (iter == rhs.iter); }
bool operator==(const T& rhs) const { return (iter == rhs); }
bool operator!=(const const_circular_iter<T>& rhs) const { return ! operator==(rhs); }
bool operator!=(const T& rhs) const { return ! operator==(rhs); }
};

struct STag
{
int id;
Expand Down
37 changes: 1 addition & 36 deletions addons/pvr.vdr.vnsi/src/tools.h
Expand Up @@ -27,39 +27,4 @@ uint64_t ntohll(uint64_t a);
uint64_t htonll(uint64_t a);

#include "libXBMC_codec.h"

class CodecDescriptor
{
public:
CodecDescriptor(void)
{
m_codec.codec_id = XBMC_INVALID_CODEC_ID;
m_codec.codec_type = XBMC_CODEC_TYPE_UNKNOWN;
}

CodecDescriptor(xbmc_codec_t codec, const char* name) :
m_codec(codec),
m_strName(name) {}
virtual ~CodecDescriptor(void) {}

const std::string& Name(void) const { return m_strName; }
xbmc_codec_t Codec(void) const { return m_codec; }

static CodecDescriptor GetCodecByName(const char* strCodecName)
{
CodecDescriptor retVal;
// some of Tvheadend's and VDR's codec names don't match ffmpeg's, so translate them to something ffmpeg understands
if (!strcmp(strCodecName, "MPEG2AUDIO"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MP2"), strCodecName);
else if (!strcmp(strCodecName, "MPEGTS"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MPEG2VIDEO"), strCodecName);
else
retVal = CodecDescriptor(CODEC->GetCodecByName(strCodecName), strCodecName);

return retVal;
}

private:
xbmc_codec_t m_codec;
std::string m_strName;
};
#include "xbmc_codec_descriptor.hpp"
65 changes: 65 additions & 0 deletions xbmc/xbmc_codec_descriptor.hpp
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#ifndef XBMC_CODEC_DESCRIPTOR_HPP
#define XBMC_CODEC_DESCRIPTOR_HPP

#include "libXBMC_codec.h"

/**
* Adapter which converts codec names used by tvheadend and VDR into their
* FFmpeg equivalents.
*/
class CodecDescriptor
{
public:
CodecDescriptor(void)
{
m_codec.codec_id = XBMC_INVALID_CODEC_ID;
m_codec.codec_type = XBMC_CODEC_TYPE_UNKNOWN;
}

CodecDescriptor(xbmc_codec_t codec, const char* name) :
m_codec(codec),
m_strName(name) {}
virtual ~CodecDescriptor(void) {}

const std::string& Name(void) const { return m_strName; }
xbmc_codec_t Codec(void) const { return m_codec; }

static CodecDescriptor GetCodecByName(const char* strCodecName)
{
CodecDescriptor retVal;
// some of Tvheadend's and VDR's codec names don't match ffmpeg's, so translate them to something ffmpeg understands
if (!strcmp(strCodecName, "MPEG2AUDIO"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MP2"), strCodecName);
else if (!strcmp(strCodecName, "MPEGTS"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MPEG2VIDEO"), strCodecName);
else
retVal = CodecDescriptor(CODEC->GetCodecByName(strCodecName), strCodecName);

return retVal;
}

private:
xbmc_codec_t m_codec;
std::string m_strName;
};

#endif /* XBMC_CODEC_DESCRIPTOR_HPP */

0 comments on commit 0ed916c

Please sign in to comment.