diff --git a/lib/NGCP/Panel/Controller/API/VoicemailRecordingsItem.pm b/lib/NGCP/Panel/Controller/API/VoicemailRecordingsItem.pm index f62d77934d..d5838bfb37 100644 --- a/lib/NGCP/Panel/Controller/API/VoicemailRecordingsItem.pm +++ b/lib/NGCP/Panel/Controller/API/VoicemailRecordingsItem.pm @@ -51,7 +51,7 @@ sub GET :Allow { my $filename = $sr->{get_voicemail_filename}($c,$item,$format); $c->response->header ('Content-Disposition' => 'attachment; filename="'.$filename.'"'); $c->response->content_type($sr->{get_voicemail_content_type}($c,$format)); - $c->response->body($ss->{transcode_data}($item->recording,'WAV',uc($format))); + $c->response->body(${$ss->{transcode_data}(\$item->recording, 'WAV', uc($format))}); return; } return; diff --git a/lib/NGCP/Panel/Controller/Sound.pm b/lib/NGCP/Panel/Controller/Sound.pm index 27a4573741..b1f9a4b2fa 100644 --- a/lib/NGCP/Panel/Controller/Sound.pm +++ b/lib/NGCP/Panel/Controller/Sound.pm @@ -683,12 +683,12 @@ sub handles_download :Chained('handles_base') :PathPart('download') :Args(0) { my $file = $c->stash->{file_result}; my $filename = $file->filename; $filename =~ s/\.\w+$/.wav/; - my $data; + my $data_ref; if($file->codec ne 'WAV') { try { - $data = NGCP::Panel::Utils::Sounds::transcode_data( - $file->data, $file->codec, 'WAV'); + $data_ref = NGCP::Panel::Utils::Sounds::transcode_data( + \$file->data, $file->codec, 'WAV'); } catch($e) { NGCP::Panel::Utils::Message::error( c => $c, @@ -698,12 +698,12 @@ sub handles_download :Chained('handles_base') :PathPart('download') :Args(0) { NGCP::Panel::Utils::Navigation::back_or($c, $c->stash->{handles_base_uri}); } } else { - $data = $file->data; + $data_ref = \$file->data; } $c->response->header ('Content-Disposition' => 'attachment; filename="' . $filename . '"'); $c->response->content_type('audio/x-wav'); - $c->response->body($data); + $c->response->body($$data_ref); return; } diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index da9fb6ebde..e76b2e05b0 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -3998,12 +3998,11 @@ sub play_voicemail :Chained('voicemail') :PathPart('play') :Args(0) { my ($self, $c) = @_; my $file = $c->stash->{voicemail}; - my $recording = $file->recording; - my $data; + my $data_ref; try { - $data= NGCP::Panel::Utils::Sounds::transcode_data( - $recording, 'WAV', 'WAV'); + $data_ref = NGCP::Panel::Utils::Sounds::transcode_data( + \$file->recording, 'WAV', 'WAV'); } catch ($e) { NGCP::Panel::Utils::Message::error( c => $c, @@ -4019,7 +4018,7 @@ sub play_voicemail :Chained('voicemail') :PathPart('play') :Args(0) { my $filename = NGCP::Panel::Utils::Subscriber::get_voicemail_filename($c,$file); $c->response->header('Content-Disposition' => 'attachment; filename="'.$filename.'"'); $c->response->content_type('audio/x-wav'); - $c->response->body($data); + $c->response->body($$data_ref); } sub delete_voicemail :Chained('voicemail') :PathPart('delete') :Args(0) { diff --git a/lib/NGCP/Panel/Utils/Sounds.pm b/lib/NGCP/Panel/Utils/Sounds.pm index 22417c16b1..5be49dff05 100644 --- a/lib/NGCP/Panel/Utils/Sounds.pm +++ b/lib/NGCP/Panel/Utils/Sounds.pm @@ -49,12 +49,12 @@ sub transcode_file { sub transcode_data { my ($data, $source_codec, $target_codec) = @_; my ($fh, $filename) = tempfile; - print $fh $data; + print $fh (ref $data ? $$data : $data); close $fh; my $out = transcode_file($filename, $source_codec, $target_codec); unlink $filename; - return $out; + return \$out; } sub stash_soundset_list {