* VRFS-2605 - compute offset and seek based on client info

This commit is contained in:
Seth Call 2015-04-21 11:26:55 -05:00
parent 8369ef0e13
commit 03072b2e8d
3 changed files with 47 additions and 19 deletions

View File

@ -1,6 +1,6 @@
module JamRuby
# sends out a boring ale
class AdminMailer < ActionMailer::Base
class AdminMailer < ActionMailer::Base
include SendGrid

View File

@ -137,15 +137,37 @@ module JamRuby
one_day = 60 * 60 * 24
jam_track_offset = 0
jam_track_seek = 0
if recording.timeline
recording_timeline_data = JSON.parse(recording.timeline)
# did the jam track play at all?
jam_track_isplaying = recording_timeline_data["jam_track_isplaying"]
recording_start_time = recording_timeline_data["recording_start_time"]
jam_track_play_start_time = recording_timeline_data["jam_track_play_start_time"]
jam_track_recording_start_play_offset = recording_timeline_data["jam_track_recording_start_play_offset"]
jam_track_offset = -jam_track_recording_start_play_offset
# how long did the JamTrack play? not needed because we limit on the input tracks, which represents how long the recording is, too
jam_track_play_time = recording_timeline_data["jam_track_play_time"]
offset = jam_track_play_start_time - recording_start_time
if offset >= 0
# jamtrack started after recording, so buffer with silence as necessary
jam_track_offset = offset
else
# jamtrack started before recording, so we can seek into it to make up for the missing parts
jam_track_seek = -offset
end
if jam_track_recording_start_play_offset < 0
# we don't know how to handle this ! alert ops
AdminMailer.alerts({subject: "negative jam_track_recording_start_play_offset mix.id=#{self.id}"})
jam_track_recording_start_play_offset = 0
end
jam_track_seek = jam_track_seek + jam_track_recording_start_play_offset
end
manifest = { "files" => [], "timeline" => [] }
@ -171,27 +193,29 @@ module JamRuby
mix_params << { "level" => 1.0, "balance" => 0 }
end
recording.recorded_jam_track_tracks.each do |recorded_jam_track_track|
manifest["files"] << { "filename" => recorded_jam_track_track.jam_track_track.sign_url(one_day), "codec" => "vorbis", "offset" => jam_track_offset }
# let's look for level info from the client
level = 1.0 # default value - means no effect
if recorded_jam_track_track.timeline
if recording.is_jamtrack_recording?
recording.recorded_jam_track_tracks.each do |recorded_jam_track_track|
manifest["files"] << { "filename" => recorded_jam_track_track.jam_track_track.sign_url(one_day), "codec" => "vorbis", "offset" => jam_track_offset, "seek" => jam_track_seek }
# let's look for level info from the client
level = 1.0 # default value - means no effect
if recorded_jam_track_track.timeline
timeline_data = JSON.parse(recorded_jam_track_track.timeline)
timeline_data = JSON.parse(recorded_jam_track_track.timeline)
# always take the 1st entry for now
first = timeline_data[0]
# always take the 1st entry for now
first = timeline_data[0]
if first["mute"]
# mute equates to no noise
level = 0.0
else
# otherwise grab the left channel...
level = first["vol_l"]
if first["mute"]
# mute equates to no noise
level = 0.0
else
# otherwise grab the left channel...
level = first["vol_l"]
end
end
end
mix_params << { "level" => level, "balance" => 0 }
mix_params << { "level" => level, "balance" => 0 }
end
end
manifest["timeline"] << { "timestamp" => 0, "mix" => mix_params }

View File

@ -51,7 +51,11 @@ module JamRuby
end
def is_jamtrack_recording?
!jam_track_id.nil?
!jam_track_id.nil? && parsed_timeline['jam_track_isplaying']
end
def parsed_timeline
timeline ? JSON.parse(timeline) : {}
end
def high_quality_mix?