diff options
author | Paul Arthur <flowerysong00@yahoo.com> | 2011-04-08 23:15:33 -0400 |
---|---|---|
committer | Paul Arthur <flowerysong00@yahoo.com> | 2011-04-08 23:26:21 -0400 |
commit | f7c1e57cf021f1d6f00b209f1640bc24c6303391 (patch) | |
tree | 31d8cbd7c1672e4121d29f659819c4d46baaeaed /lib/class/song.class.php | |
parent | 4aa256cb07ee2dd0a113b56b06accf1dae2c61c7 (diff) | |
download | ampache-f7c1e57cf021f1d6f00b209f1640bc24c6303391.tar.gz ampache-f7c1e57cf021f1d6f00b209f1640bc24c6303391.tar.bz2 ampache-f7c1e57cf021f1d6f00b209f1640bc24c6303391.zip |
Transcoding/streaming cleanup.
Derive our new filesize from the length, not the previous bitrate and
size. Allow higher bitrates than the source when they're different
formats. Return HTTP error codes when an error occurs. Minor cleanup.
Diffstat (limited to 'lib/class/song.class.php')
-rw-r--r-- | lib/class/song.class.php | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php index b6899267..1d5329a0 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -63,7 +63,10 @@ class Song extends database_object implements media { /* Setting Variables */ public $_transcoded = false; + public $resampled = false; public $_fake = false; // If this is a 'construct_from_array' object + public $transcoded_from; + private $_transcode_cmd; /** * Constructor @@ -970,10 +973,20 @@ class Song extends database_object implements media { $conf_var = 'transcode_' . $this->type; $conf_type = 'transcode_' . $this->type . '_target'; + $conf_cmd = 'transcode_cmd_' . $this->type; if (Config::get($conf_var)) { $this->_transcoded = true; - debug_event('auto_transcode','Transcoding to ' . $this->type,'5'); + $this->_transcoded_from = $this->type; + $this->_transcode_cmd = Config::get($conf_cmd); + + $this->format_type(Config::get($conf_type)); + if ($this->type == $this->_transcoded_from) { + $this->_resampled = true; + } + + debug_event('transcode', 'Transcoding from ' . + $this->_transcoded_from . ' to ' . $this->type, 5); return false; } @@ -983,26 +996,17 @@ class Song extends database_object implements media { /** * stream_cmd + * * test if the song type streams natively and * if not returns a transcoding command from the config - * we can't use this->type because its been formated for the - * downsampling */ public function stream_cmd() { - // Find the target for this transcode - $conf_type = 'transcode_' . $this->type . '_target'; - $stream_cmd = 'transcode_cmd_' . $this->type; - $this->format_type(Config::get($conf_type)); - - if (Config::get($stream_cmd)) { - return $stream_cmd; + if ($this->native_stream()) { + return null; } - else { - debug_event('Downsample','Error: Transcode ' . $stream_cmd . ' for ' . $this->type . ' not found, using downsample','2'); - } - - return false; + + return $this->_transcode_cmd; } // end stream_cmd |