~ubuntu-branches/ubuntu/vivid/mediatomb/vivid

« back to all changes in this revision

Viewing changes to src/transcoding/transcoding.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2008-03-02 13:09:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080302130916-zlljdze3kt7vuq4b
Tags: 0.11.0-1
* New upstream release.
* Include message about which inotify headers will be used when enabling
  inotify runtime support.
* Fixed error with use of INTERFACE in init script. Also removed use of -m
  option.
* Including new config.xml options.
* Added more build dependencies for new upstream release.
* Removed build dependency of libid3-dev, taglib is now preferred.
* mediatomb.xpm and manpage.xml is now included in orig tarball.
* inotify patch is not needed anymore.
* md5 patch has been committed upstream and is no longer needed. Also removed
  README.Debian.
* TwinHelix PNG fix is now used. Removed from TODO.
* Adding dependency of iceweasel for mediatomb package.
* Updated copyright file.
* Updated watch file.
* Updated rules file for proper configure options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*MT*
 
2
    
 
3
    MediaTomb - http://www.mediatomb.cc/
 
4
    
 
5
    transcoding.h - this file is part of MediaTomb.
 
6
    
 
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
 
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
 
9
    
 
10
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
 
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
 
12
                            Leonhard Wimmer <leo@mediatomb.cc>
 
13
    
 
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.
 
17
    
 
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.
 
22
    
 
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.
 
26
    
 
27
    $Id: transcoding.h 1698 2008-02-23 20:48:30Z lww $
 
28
*/
 
29
 
 
30
/// \file transcoding.h
 
31
/// \brief Definitions of the Transcoding classes. 
 
32
 
 
33
#ifdef EXTERNAL_TRANSCODING
 
34
 
 
35
#ifndef __TRANSCODING_H__
 
36
#define __TRANSCODING_H__
 
37
 
 
38
#include "zmmf/zmmf.h"
 
39
#include "dictionary.h"
 
40
#include "object_dictionary.h"
 
41
 
 
42
typedef enum transcoding_type_t
 
43
{
 
44
    TR_None,
 
45
    TR_External,
 
46
    TR_Remote
 
47
};
 
48
 
 
49
typedef enum avi_fourcc_listmode_t
 
50
{
 
51
    FCC_None,
 
52
    FCC_Process,
 
53
    FCC_Ignore
 
54
};
 
55
 
 
56
/// \brief this class keeps all data associated with one transcoding profile.
 
57
class TranscodingProfile : public zmm::Object
 
58
{
 
59
public:
 
60
    TranscodingProfile(transcoding_type_t tr_type, zmm::String name);
 
61
 
 
62
    /// \brief returns the transcoding type.
 
63
    transcoding_type_t getType() { return tr_type; }
 
64
 
 
65
    /// \brief set name of the transcoding profile
 
66
    void setName(zmm::String name) { this->name = name; }
 
67
 
 
68
    /// \brief get name of the transcoding profile
 
69
    zmm::String getName() { return name; }
 
70
 
 
71
    /// \brief set target mimetype
 
72
    ///
 
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; }
 
76
 
 
77
    /// \brief get target mimetype
 
78
    zmm::String getTargetMimeType() { return tm; }
 
79
 
 
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; }
 
83
 
 
84
    /// \brief gets the transcoders program name
 
85
    zmm::String getCommand() { return command; }
 
86
 
 
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);
 
94
 
 
95
    size_t getBufferSize() { return buffer_size; }
 
96
    size_t getBufferChunkSize() { return chunk_size; }
 
97
    size_t getBufferInitialFillSize() { return initial_fill_size; }
 
98
 
 
99
    /// \brief sets the arguments that will be fed to the transcoder,
 
100
    /// this is the string that comes right after the command.
 
101
    /// 
 
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; }
 
109
 
 
110
    /// \brief retrieves the argument string
 
111
    zmm::String getArguments() { return args; }
 
112
 
 
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; }
 
116
 
 
117
    /// \brief Adds a resource attribute.
 
118
    ///
 
119
    /// This maps to an attribute of the <res> tag in the DIDL-Lite XML.
 
120
    ///
 
121
    /// \param name attribute name 
 
122
    /// \param value attribute value
 
123
    void addAttribute(zmm::String name, zmm::String value);
 
124
 
 
125
    zmm::Ref<Dictionary> getAttributes();
 
126
 
 
127
    /// \brief Override for theora content.
 
128
    ///
 
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; }
 
135
 
 
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; }
 
140
 
 
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; }
 
145
 
 
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; }
 
150
 
 
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.
 
156
    ///
 
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);
 
161
 
 
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; }
 
166
 
 
167
protected:
 
168
    zmm::String name;
 
169
    zmm::String tm;
 
170
    zmm::String command;
 
171
    zmm::String args;
 
172
    bool first_resource;
 
173
    bool theora;
 
174
    bool accept_url;
 
175
    bool hide_orig_res;
 
176
    bool thumbnail;
 
177
    size_t buffer_size;
 
178
    size_t chunk_size;
 
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();
 
185
};
 
186
 
 
187
/// \brief this class allows access to available transcoding profiles.
 
188
class TranscodingProfileList : public zmm::Object
 
189
{
 
190
public:
 
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(); }
 
197
protected:
 
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;
 
202
};
 
203
 
 
204
class TranscodingProcess : public zmm::Object
 
205
{
 
206
public:
 
207
    TranscodingProcess(pid_t pid, zmm::String fname) 
 
208
                       { this->pid = pid; this->fname = fname; }
 
209
 
 
210
    pid_t getPID() { return pid; }
 
211
    zmm::String getFName() { return fname; }
 
212
 
 
213
protected:
 
214
    pid_t pid;
 
215
    zmm::String fname;
 
216
};
 
217
 
 
218
 
 
219
 
 
220
#endif//__TRANSCODING_H__
 
221
 
 
222
#endif//TRANSCODING