Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.5.18] recording: multiuser whiteboard cursor #218

Open
wants to merge 2 commits into
base: test2.5.18_diff_multiCursorRecord
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 78 additions & 6 deletions record-and-playback/presentation/scripts/publish/presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,10 @@ def process_presentation(package_dir)
slides = []
panzooms = []
cursors = []
cursors_all = {}
shapes = {}
presenters = []
participants = {}

# Iterate through the events.xml and store the events, building the
# xml files as we go
Expand Down Expand Up @@ -860,6 +863,12 @@ def process_presentation(package_dir)
presenter = event.at_xpath('userid').text
cursor_visible = false
cursor_changed = true
presenter_changed = true

when 'ParticipantJoinEvent'
name_participant = event.at_xpath('name').text
userId_participant = event.at_xpath('userId').text
participants[userId_participant] = name_participant

when 'CursorMoveEvent'
cursor_x = event.at_xpath('xOffset').text.to_f
Expand All @@ -868,12 +877,10 @@ def process_presentation(package_dir)

when 'WhiteboardCursorMoveEvent'
user_id = event.at_xpath('userId')&.text
# Only draw cursor for current presentor. TODO multi-cursor support
if !user_id || user_id == presenter
cursor_x = event.at_xpath('xOffset').text.to_f
cursor_y = event.at_xpath('yOffset').text.to_f
cursor_visible = cursor_changed = true
end
cursor_x = event.at_xpath('xOffset').text.to_f
cursor_y = event.at_xpath('yOffset').text.to_f
cursor_visible = cursor_changed = true
cursor_userId = user_id if user_id && user_id != presenter
end
# Perform slide finalization
if slide_changed
Expand Down Expand Up @@ -902,6 +909,13 @@ def process_presentation(package_dir)
end
end

# Presenter finalization
if presenter_changed &&
(presenters.empty? ||
(presenters[-1][:timestamp] != timestamp || presenters[-1][:userId] != presenter))
presenters << {timestamp: timestamp, userId: presenter}
end

# Perform panzoom finalization
if panzoom_changed
slide = slides.last
Expand Down Expand Up @@ -965,6 +979,20 @@ def process_presentation(package_dir)
in: timestamp,
}
cursors << cursor

if !cursor_userId && presenter
if cursors_all[presenter]
cursors_all[presenter].push(cursor)
else
cursors_all[presenter] = [cursor]
end
elsif cursor_userId && cursor_userId != ""
if cursors_all[cursor_userId]
cursors_all[cursor_userId].push(cursor)
else
cursors_all[cursor_userId] = [cursor]
end
end
end
end
end
Expand All @@ -984,6 +1012,44 @@ def process_presentation(package_dir)
cursors_doc.instruct!
cursors_doc.recording(id: 'cursor_events') { |xml| xml << cursors_rec.target! }

cursors_all.each do |uid, cs|
cs.last[:out] = last_timestamp
end
cursors_all_doc = Nokogiri::XML::Builder.new do |xml|
xml.recording(:id => 'cursor_all_events') do
cursors_all.each do |uid, cs|
xml.user(:userId => uid) do |user|
cs.each do |c|
cursors_emit_event(user, c)
end
end
end
end
end
#BigBlueButton.logger.info("CURSORALL #{cursors_all}")

#BigBlueButton.logger.info("PRESENTERS #{presenters}")
presenters_doc = Nokogiri::XML::Builder.new do |xml|
xml.recording(:id => 'assign_presenter_events') do
presenters.each do |p|
xml.event(:timestamp => p[:timestamp]) do
xml.userId(p[:userId])
end
end
end
end

#BigBlueButton.logger.info("PARTICIPANTS #{participants}")
participants_doc = Nokogiri::XML::Builder.new do |xml|
xml.recording(:id => 'participants_names') do
participants.each do |k, v|
xml.participant(:userId => k) do
xml.name(v)
end
end
end
end

panzooms_doc = Builder::XmlMarkup.new(indent: 2)
panzooms_doc.instruct!
panzooms_doc.recording(id: 'panzoom_events') { |xml| xml << panzooms_rec.target! }
Expand All @@ -992,6 +1058,9 @@ def process_presentation(package_dir)
File.write("#{package_dir}/#{@shapes_svg_filename}", shapes_doc.to_xml)
File.write("#{package_dir}/#{@panzooms_xml_filename}", panzooms_doc.target!)
File.write("#{package_dir}/#{@cursor_xml_filename}", cursors_doc.target!)
File.write("#{package_dir}/#{@cursors_xml_filename}", cursors_all_doc.to_xml)
File.write("#{package_dir}/#{@presenters_xml_filename}", presenters_doc.to_xml)
File.write("#{package_dir}/#{@participants_xml_filename}", participants_doc.to_xml)
end

def process_chat_messages(events, bbb_props)
Expand Down Expand Up @@ -1169,6 +1238,9 @@ def copy_media_files_helper(media, media_files, package_dir)
@shapes_svg_filename = 'shapes.svg'
@panzooms_xml_filename = 'panzooms.xml'
@cursor_xml_filename = 'cursor.xml'
@cursors_xml_filename = 'cursors.xml'
@presenters_xml_filename = 'presenters.xml'
@participants_xml_filename = 'participants.xml'
@deskshare_xml_filename = 'deskshare.xml'
@svg_shape_id = 1
@svg_shape_unique_id = 1
Expand Down
Loading