3
MediaTomb - http://www.mediatomb.cc/
5
transcoding.h - this file is part of MediaTomb.
7
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
10
Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
11
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
Leonhard Wimmer <leo@mediatomb.cc>
14
MediaTomb is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License version 2
16
as published by the Free Software Foundation.
18
MediaTomb is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
version 2 along with MediaTomb; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
27
$Id: transcoding.h 1698 2008-02-23 20:48:30Z lww $
30
/// \file transcoding.h
31
/// \brief Definitions of the Transcoding classes.
33
#ifdef EXTERNAL_TRANSCODING
35
#ifndef __TRANSCODING_H__
36
#define __TRANSCODING_H__
38
#include "zmmf/zmmf.h"
39
#include "dictionary.h"
40
#include "object_dictionary.h"
42
typedef enum transcoding_type_t
49
typedef enum avi_fourcc_listmode_t
56
/// \brief this class keeps all data associated with one transcoding profile.
57
class TranscodingProfile : public zmm::Object
60
TranscodingProfile(transcoding_type_t tr_type, zmm::String name);
62
/// \brief returns the transcoding type.
63
transcoding_type_t getType() { return tr_type; }
65
/// \brief set name of the transcoding profile
66
void setName(zmm::String name) { this->name = name; }
68
/// \brief get name of the transcoding profile
69
zmm::String getName() { return name; }
71
/// \brief set target mimetype
73
/// The so called "target mimetype" is the mimetype of the media that will
74
/// be produced by the transcoder and identifies the target format.
75
void setTargetMimeType(zmm::String tm) { this->tm = tm; }
77
/// \brief get target mimetype
78
zmm::String getTargetMimeType() { return tm; }
80
/// \brief sets the program name, i.e. the command line name of the
81
/// transcoder that will be executed.
82
void setCommand(zmm::String command) { this->command = command; }
84
/// \brief gets the transcoders program name
85
zmm::String getCommand() { return command; }
87
/// \brief set buffering options
88
/// \param bs the size of the buffer in bytes
89
/// \param cs the maximum size of the chunks which are read by the buffer
90
/// \param ifs the number of bytes which have to be in the buffer
91
/// before the first read at the very beginning or after a seek returns;
92
/// 0 disables the delay
93
void setBufferOptions(size_t bs, size_t cs, size_t ifs);
95
size_t getBufferSize() { return buffer_size; }
96
size_t getBufferChunkSize() { return chunk_size; }
97
size_t getBufferInitialFillSize() { return initial_fill_size; }
99
/// \brief sets the arguments that will be fed to the transcoder,
100
/// this is the string that comes right after the command.
102
/// The argument string must contain the special %out token and may contain
103
/// the special %in token. The %in token is replaced by the filename of the
104
/// appropriate item - this is the source media for the transcoder. The
105
/// %out token is replaced by the fifo name that is generated when the
106
/// transcoding process is launched. Transcoded data will be read by
107
/// the server from the fifo and served via HTTP to the renderer.
108
void setArguments(zmm::String args) { this->args = args; }
110
/// \brief retrieves the argument string
111
zmm::String getArguments() { return args; }
113
/// \brief identifies if the profile should be set as the first resource
114
void setFirstResource(bool fr) { first_resource = fr; }
115
bool firstResource() { return first_resource; }
117
/// \brief Adds a resource attribute.
119
/// This maps to an attribute of the <res> tag in the DIDL-Lite XML.
121
/// \param name attribute name
122
/// \param value attribute value
123
void addAttribute(zmm::String name, zmm::String value);
125
zmm::Ref<Dictionary> getAttributes();
127
/// \brief Override for theora content.
129
/// I could not find a more generic way for this, I guess this could
130
/// be extended to a dictionary style options if more things like that
131
/// become necessary; we need a possibility to have a more fine grained
132
/// detection of content where mimetype alone is not enough.
133
void setTheora(bool theora) { this->theora = theora; }
134
bool isTheora() { return theora; }
136
/// \brief Specifies if the transcoding profile directly accepts an URL
137
/// or if we should proxy the data.
138
void setAcceptURL(bool accept) { accept_url = accept; }
139
bool acceptURL() { return accept_url; }
141
/// \brief Specifies if the output of the profile is a thumbnail,
142
/// this will add appropriate DLNA tags to the XML.
143
void setThumbnail(bool th) { thumbnail = th; }
144
bool isThumbnail() { return thumbnail; }
146
/// \brief Specifies if the availability of this transcoding profile
147
/// should enforce hiding of all original resources in the browse XML
148
void setHideOriginalResource(bool hide) { hide_orig_res = hide; }
149
bool hideOriginalResource() { return hide_orig_res; }
151
/// \brief If the profile handles source content in the AVI container,
152
/// we can specify a list of fourcc's; the list can be either processed
153
/// (i.e. the profile will process only AVI files that have a fourcc which
154
/// matches an entry in the list), or we can specify that the AVIs that
155
/// match a fourcc in the list are ignored and not transcoded.
157
/// \param list List of FourCC entries.
158
/// \param mode Specifies if the FourCCs in the list are accepted or ignored
159
void setAVIFourCCList(zmm::Ref<zmm::Array<zmm::StringBase> > list,
160
avi_fourcc_listmode_t mode = FCC_Ignore);
162
/// \brief Retrieves the FourCC list
163
zmm::Ref<zmm::Array<zmm::StringBase> > getAVIFourCCList();
164
/// \brief Provides information on the mode of the list
165
avi_fourcc_listmode_t getAVIFourCCListMode() { return fourcc_mode; }
179
size_t initial_fill_size;
180
transcoding_type_t tr_type;
181
zmm::Ref<Dictionary> attributes;
182
zmm::Ref<zmm::Array<zmm::StringBase> > fourcc_list;
183
avi_fourcc_listmode_t fourcc_mode;
184
TranscodingProfile();
187
/// \brief this class allows access to available transcoding profiles.
188
class TranscodingProfileList : public zmm::Object
191
TranscodingProfileList();
192
void add(zmm::String sourceMimeType, zmm::Ref<TranscodingProfile> prof);
193
zmm::Ref<ObjectDictionary<TranscodingProfile> > get(zmm::String sourceMimeType);
194
zmm::Ref<ObjectDictionary<TranscodingProfile> > get(int index);
195
zmm::Ref<TranscodingProfile> getByName(zmm::String name);
196
inline int size() { return list->size(); }
198
// outer dictionary is keyed by the source mimetype, inner dictionary by
199
// profile name; this whole construction is necessary to allow to transcode
200
// to the same output format but vary things like resolution, bitrate, etc.
201
zmm::Ref<ObjectDictionary<ObjectDictionary<TranscodingProfile> > > list;
204
class TranscodingProcess : public zmm::Object
207
TranscodingProcess(pid_t pid, zmm::String fname)
208
{ this->pid = pid; this->fname = fname; }
210
pid_t getPID() { return pid; }
211
zmm::String getFName() { return fname; }
220
#endif//__TRANSCODING_H__