Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Sync Player

53 views

Published on

use bluetooth to make several devices to play the same video at the same time

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Sync Player

  1. 1. SyncPlayer James Huang
  2. 2. Outline 1. Framework 2. Connection 3. Synchronization 4. Playing video
  3. 3. Framework • Host Flow • Client Flow • Implementation
  4. 4. Homepage 1.Choose the character you want to play 2.Turn on the bluetooth
  5. 5. Create a New Room (Host) 1. Assign a room name 2. Brand new room name or Historical room name
  6. 6. Room Setting (Host) 1. Choose video source 2. Assign character to each client 3. Video source can be local or YouTube Choose local fileWaiting Room
  7. 7. Synchronization 1.Host can control play and stop 2. Client can leave at any time
  8. 8. Client 1. Search nearby host room
  9. 9. Server’s flow Client name list YouTube document History list (named by server) New films Control bar starthistory dismiss start save room name new Ok Name for server
  10. 10. Client’s flow cancelready filmsRoom list (searched Bluetooth name) Client name list startjoin History auto join(message send by server) YouTube document
  11. 11. Connection Flow Server Side Client Side 1.Server becomes discoverable and initialize bluetoothSocket 2.Client scan nearby device Scan request Return MAC address and device INFOBluetoothServerSocket
  12. 12. RFCOMM channel Connection Flow Server Side Client Side bluetoothSocket listen to Certain UUID: listenUsingRfcommWithServiceRecord(Str ing, UUID) 3.Client initialize bluetoothSocket use certain UUID connect to Server Connect(MAC,UUID) BluetoothServerSocket BluetoothSocket Accept() BluetoothSocket Accept() 4.Server close BluetoothServerSocket and get BluetoothSocket after connection confirm
  13. 13. RFCOMM channel Connection Flow Server Side Client Side 5.Now server and client can transmit data in bidirection by BluetoothSocket BluetoothSocket BluetoothSocket
  14. 14. Service discovery protocol (SDP) 
 • Used to allow devices to discover what services each other support, and what parameters to use to connect to them. • Each service is identified by a Universally Unique Identifier (UUID) • specification defines a way to represent a range of UUIDs (which are nominally 128-bits) in a shorter form(16 -bits) • Bluetooth service UUID range: 0000xxxx-0000-1000-8000-00805F9B34FB
  15. 15. Multiple client BluetoothServerSocket1 listen(UUID1) connect (MAC,UUID_list[i]) connect (MAC,UUID_list[i])) client1server client2 ... ID UUID 1 …… 2 …… … …… UUID list Used by which client …… Client1 …… Client2 …… … ... BluetoothServerSocket1 listen(UUID2) BluetoothServerSocket1 listen(UUIDn) Unlike TCP/IP, RFCOMM only allows one connected client per channel at a time
  16. 16. Multiple client RFCOMM channel Server Side Client1 Side BluetoothSocket BluetoothServerSocket1 BluetoothServerSocket2 Client2 Side BluetoothSocket ... ...
  17. 17. Multiple client RFCOMM channel Server Side Client1 Side BluetoothSocket BluetoothSocket1 BluetoothSocket2 Client2 Side BluetoothSocket ... ...
  18. 18. Inter Process Communication Server Service Client1 Service BluetoothSocket BluetoothSocket1 BluetoothSocket2 Client2 Service BluetoothSocket ... ... client Manager Video player RoleInfo Video player RoleInfo Video player IPC IPC IPC IPC IPC IPC
  19. 19. Synchronization Technique • Network Time Protocol • Synchronize the time of every devices based on the host • Reduce the delay caused by transmission
  20. 20. Synchronization Technique • Procedures: • Client requests server at T0 • Server receives the request and records the current time T1 • Server sends the message (T1) with the current time T2 • Client receives the message at T3, then calculates: • RTT = [(T3-T0)-(T2-T1)]/2 • Calculate the time difference Δt = T3-T2-RTT
  21. 21. Play the Video • Use MediaPlayer • Support mp4, 3gp, avi • Host assigns characters to the clients • Video, Left/Right Channel
  22. 22. Playing the Video • Do NTP every time when Play, Pause, and Stop • Only the host can control the video to play or stop
  23. 23. Video Source • Local Files • Every devices should have the file • Host chooses the video and informs clients • YouTube • Cannot control and synchronize

×