Remote server recorder
This class acts as a recorder that receives media from a camera and records it to the network. E.g. the server can be configured to receive video from a FFmpeg player and send it to the network where a client player plays the video.
- exception cpl_media.remote.server.EndConnection
- Bases: - Exception- Raised when the connection is closed. 
- class cpl_media.remote.server.RemoteData
- Bases: - object- Provides methods to send and receive messages from a socket. - decode_data(msg_buff, msg_len)
- Decodes buffer data received from the network. - Parameters:
- msg_buff – The bytes data received so far. 
- msg_len – The expected size of the message as tuple - The size of the message and any associated binary data. 
 
- Returns:
- A tuple of the message name and value, or (None, None) if we haven’t read the full message. 
 
 - read_msg(sock, msg_len, msg_buff)
- Reads the message and decodes it once we read the full message. - Parameters:
- sock – The socket. 
- msg_len – The tuple of the message length and associated data. If empty, the start of the next message will provide this information. 
- msg_buff – The message buffer. 
 
- Returns:
- A 4-tuple of - (msg_len, msg_buff, msg, value). Where- msg_len, msg_buffare similar to the input, and- (msg, value)is the message and its value if we read a full message, otherwise they are None.
 
 - send_msg(sock, msg, value)
- Sends message to the server. - Parameters:
- sock – The socket 
- msg – The message name string (e.g. image). 
- value – The message value. 
 
- Returns:
 
 
- class cpl_media.remote.server.RemoteRecordSettingsWidget(recorder=None, **kwargs)
- Bases: - BoxLayout- Settings widget for - RemoteVideoRecorder.- recorder: RemoteVideoRecorder = None
- The recorder. 
 
- class cpl_media.remote.server.RemoteVideoRecorder(**kwargs)
- Bases: - BaseRecorder,- RemoteData- A server recorder that takes images from a player and sends it to a client player over a socket. - The server is intended to be started before anything else can be processed. Once the server is run, we can start recording (whether a client is connected or not). If the client is not playing, we don’t send frames and just skip them. - A client should accept these messages: exception, started_recording, stopped_recording, or image. Server accepts messages from client: started_playing, stopped_playing. - We send started_recording in response to started_playing request. Either immediately if we were already recording, or later when we start. We send stopped_recording in response to stopping recording, if the client was between started_playing and stopped_playing (i.e. it expected to get images). We send images if between started_playing and stopped_playing requests and if we are recording. - We only accept started_playing either before any started_playing message or after a stopped_playing message (i.e. no duplicates). - _config_props_: Tuple[str] = ('server', 'port', 'timeout', 'max_images_buffered')
- A list of configurable property names of the class that is set/read by the configuration API. - Each sub/super-class can define this and the properties are accumulated across all the sub/super-classes. 
 - from_kivy_queue = None
- The queue that receives messages from Kivy. - This queue can receive these messages: eof, image, started_recording, or stopped_recording. 
 - max_images_buffered
- How many images the server should buffer before it starts dropping images, rather than queuing them to be sent to the client. 
 - port
- The server port on which to broadcast the data. 
 - process_in_kivy_thread(*largs)
- Processes messages from the server in the kivy thread. 
 - record(*largs, **kwargs)
- Starts recording from the provided player and sets the - record_stateto starting.- May be called from main kivy thread only. - May only be called when - record_stateis none, otherwise an exception is raised. Similarly, only when the player’s play state is playing. The players metadata_play_used, must also have been set to the value it’s using.- Recorders need to eventually call - complete_start()to finish starting recording.
 - record_thread_run(*largs)
- The method that runs in the internal record thread. 
 - send_image_to_client(image)
- Sends a image (tuple of image, metadata) to the client through the server. 
 - send_message_to_client(msg, value)
- Sends the message to the client through the server. - Parameters:
- msg – The message name string. 
- value – The message value. 
 
 
 - server
- The server address on which to broadcast the data. 
 - server_active
- Whether the server is currently running. 
 - server_run(from_kivy_queue, to_kivy_queue)
- Server method, that is executed in the internal server thread. 
 - server_thread = None
- The server thread instance. 
 - stop(*largs, join=False)
- Stops recording from the player, if it is recording and sets the - record_stateto stopping.- Recorders need to eventually call - complete_stop()to finish stopping recording.- Parameters:
- join – whether to block the thread until the internal record thread has exited. 
- Returns:
- Whether we stopped recording (True) or were already stop(ping/ed) recording. 
 
 - stop_all(join=False)
- Causes all internal threads to stop and exit. - Parameters:
- join – Whether to wait and block the calling thread until the internal threads exit. 
 
 - stop_server(join=False)
- Stops the server and also stops recording if we were recording. 
 - timeout
- How long to wait before timing out when reading data before checking the queue for other requests. 
 - to_kivy_queue = None
- The queue that sends messages to Kivy.