2
* Copyright (C) 2011 Nokia Corporation.
4
* Author: Jens Georg <jensg@openismus.com>
6
* This file is part of Rygel.
8
* Rygel is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* Rygel is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with this program; if not, write to the Free Software Foundation,
20
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
* Base class for all transcoders that handle audio.
28
internal class Rygel.AudioTranscoder : Rygel.Transcoder {
29
protected int audio_bitrate;
30
protected Caps container_format = null;
31
protected Caps audio_codec_format = null;
33
public const string NO_CONTAINER = null;
35
public AudioTranscoder (string content_type,
38
string? container_caps,
39
string audio_codec_caps,
41
base (content_type, dlna_profile, AudioItem.UPNP_CLASS, extension);
43
this.audio_bitrate = audio_bitrate;
44
if (container_caps != null) {
45
this.container_format = Caps.from_string (container_caps);
48
this.audio_codec_format = Caps.from_string (audio_codec_caps);
51
public AudioTranscoder.with_class (string content_type,
55
string? container_caps,
56
string audio_codec_caps,
58
base (content_type, dlna_profile, upnp_class, extension);
60
this.audio_bitrate = audio_bitrate;
61
if (container_caps != null) {
62
this.container_format = Caps.from_string (container_caps);
65
this.audio_codec_format = Caps.from_string (audio_codec_caps);
69
public override DIDLLiteResource? add_resource (DIDLLiteItem didl_item,
71
TranscodeManager manager)
73
var resource = base.add_resource (didl_item, item, manager);
74
if (resource == null) {
78
resource.bitrate = (this.audio_bitrate * 1000) / 8;
83
public override uint get_distance (MediaItem item) {
84
if (!(item is AudioItem) || item is VideoItem) {
88
var audio_item = item as AudioItem;
89
var distance = uint.MIN;
91
if (audio_item.bitrate > 0) {
92
distance += (audio_item.bitrate - this.audio_bitrate).abs ();
98
protected override EncodingProfile get_encoding_profile () {
99
var enc_audio_profile = new EncodingAudioProfile (audio_codec_format,
103
enc_audio_profile.set_name ("audio");
105
if (this.container_format != null) {
106
var enc_container_profile = new EncodingContainerProfile ("container",
110
enc_container_profile.add_profile (enc_audio_profile);
112
return enc_container_profile;
115
return enc_audio_profile;