paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Enumerations | Functions | Variables
vss.c File Reference

The virtual streaming system. More...

#include <sys/socket.h>
#include <netinet/in.h>
#include <regex.h>
#include <osl.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/un.h>
#include <netdb.h>
#include <lopsub.h>
#include "server.lsg.h"
#include "para.h"
#include "error.h"
#include "portable_io.h"
#include "fec.h"
#include "string.h"
#include "afh.h"
#include "afs.h"
#include "net.h"
#include "server.h"
#include "list.h"
#include "sched.h"
#include "send.h"
#include "vss.h"
#include "ipc.h"
#include "fd.h"

Macros

#define MAP_POPULATE   0
 As of 2018, neither FreeBSD-11.2 nor NetBSD-8.0 have MAP_POPULATE. More...
 

Enumerations

enum  afs_socket_status { AFS_SOCKET_READY, AFS_SOCKET_CHECK_FOR_WRITE, AFS_SOCKET_AFD_PENDING }
 The possible states of the afs socket. More...
 
enum  fec_client_state { FEC_STATE_NONE = 0, FEC_STATE_DISABLED, FEC_STATE_READY_TO_RUN }
 A FEC client is always in one of these states. More...
 

Functions

struct timeval * vss_chunk_time (void)
 Get the chunk time of the current audio file. More...
 
size_t vss_get_fec_eof_packet (const char **buf)
 Return a buffer that marks the end of the stream. More...
 
struct fec_client * vss_add_fec_client (struct sender_client *sc, struct fec_client_parms *fcp)
 Add one entry to the list of active fec clients. More...
 
void vss_del_fec_client (struct fec_client *fc)
 Remove one entry from the list of active fec clients. More...
 
unsigned int vss_playing (void)
 Check if vss status flag P (playing) is set. More...
 
unsigned int vss_next (void)
 Check if the N (next) status flag is set. More...
 
unsigned int vss_repos (void)
 Check if a reposition request is pending. More...
 
unsigned int vss_paused (void)
 Check if the vss is currently paused. More...
 
unsigned int vss_stopped (void)
 Check if the vss is currently stopped. More...
 
void vss_init (int afs_socket, struct sched *s)
 Initialize the virtual streaming system task. More...
 
void vss_shutdown (void)
 Turn off the virtual streaming system. More...
 

Variables

struct misc_meta_datammd
 Pointer to shared memory area for communication between para_server and its children. More...
 
const struct sender udp_sender dccp_sender http_sender
 The HTTP sender. More...
 
const struct sender *const senders []
 NULL-terminated list, defined in vss.c. More...
 

Detailed Description

The virtual streaming system.

This contains the audio streaming code of para_server which is independent of the current audio format, audio file selector and of the activated senders.

Macro Definition Documentation

◆ MAP_POPULATE

#define MAP_POPULATE   0

As of 2018, neither FreeBSD-11.2 nor NetBSD-8.0 have MAP_POPULATE.

Enumeration Type Documentation

◆ afs_socket_status

The possible states of the afs socket.

Enumerator
AFS_SOCKET_READY 

Socket is inactive.

AFS_SOCKET_CHECK_FOR_WRITE 

Socket fd was monitored for writing.

AFS_SOCKET_AFD_PENDING 

vss wrote a request to the socket and waits for reply from afs.

◆ fec_client_state

A FEC client is always in one of these states.

Enumerator
FEC_STATE_NONE 

not initialized and not enabled

FEC_STATE_DISABLED 

temporarily disabled

FEC_STATE_READY_TO_RUN 

initialized and enabled

Function Documentation

◆ vss_chunk_time()

struct timeval* vss_chunk_time ( void  )

Get the chunk time of the current audio file.

Returns
A pointer to a struct containing the chunk time, or NULL, if currently no audio file is selected.

References misc_meta_data::afd, audio_file_data::afhi, afh_info::chunk_tv, and mmd.

◆ vss_get_fec_eof_packet()

size_t vss_get_fec_eof_packet ( const char **  buf)

Return a buffer that marks the end of the stream.

Parameters
bufResult pointer.
Returns
The length of the eof buffer.

This is used for (multicast) udp streaming where closing the socket on the sender might not give rise to an eof condition at the peer.

References FEC_EOF_PACKET, and FEC_HEADER_SIZE.

◆ vss_add_fec_client()

struct fec_client* vss_add_fec_client ( struct sender_client sc,
struct fec_client_parms fcp 
)

Add one entry to the list of active fec clients.

Parameters
scGeneric sender_client data of the transport layer.
fcpFEC parameters as supplied by the transport layer.
Returns
Newly allocated fec_client struct.

References zalloc().

◆ vss_del_fec_client()

void vss_del_fec_client ( struct fec_client *  fc)

Remove one entry from the list of active fec clients.

Parameters
fcThe client to be removed.

◆ vss_playing()

unsigned int vss_playing ( void  )

Check if vss status flag P (playing) is set.

Returns
Greater than zero if playing, zero otherwise.

References mmd, misc_meta_data::new_vss_status_flags, and VSS_PLAYING.

◆ vss_next()

unsigned int vss_next ( void  )

Check if the N (next) status flag is set.

Returns
Greater than zero if set, zero if not.

References mmd, misc_meta_data::new_vss_status_flags, and VSS_NEXT.

◆ vss_repos()

unsigned int vss_repos ( void  )

Check if a reposition request is pending.

Returns
Greater than zero if true, zero otherwise.

References mmd, misc_meta_data::new_vss_status_flags, and VSS_REPOS.

◆ vss_paused()

unsigned int vss_paused ( void  )

Check if the vss is currently paused.

Returns
Greater than zero if paused, zero otherwise.

References mmd, misc_meta_data::new_vss_status_flags, VSS_NEXT, and VSS_PLAYING.

◆ vss_stopped()

unsigned int vss_stopped ( void  )

Check if the vss is currently stopped.

Returns
Greater than zero if paused, zero otherwise.

References mmd, misc_meta_data::new_vss_status_flags, VSS_NEXT, and VSS_PLAYING.

◆ vss_init()

void vss_init ( int  afs_socket,
struct sched s 
)

Initialize the virtual streaming system task.

Parameters
afs_socketThe fd for communication with afs.
sThe scheduler to register the vss task to.

This also initializes all supported senders and starts streaming if the –autoplay command line flag was given.

References ms2tv(), OPT_UINT32_VAL, PARA_INFO_LOG, and tv2ms().

◆ vss_shutdown()

void vss_shutdown ( void  )

Turn off the virtual streaming system.

This is only executed on exit. It calls the ->shutdown method of all senders.

References FOR_EACH_SENDER, PARA_NOTICE_LOG, process_is_command_handler(), senders, and sender::shutdown.

Variable Documentation

◆ mmd

struct misc_meta_data* mmd
extern

Pointer to shared memory area for communication between para_server and its children.

Exported to vss.c, command.c and to afs.

Referenced by vss_chunk_time(), vss_next(), vss_paused(), vss_playing(), vss_repos(), and vss_stopped().

◆ http_sender

const struct sender udp_sender dccp_sender http_sender
extern

The HTTP sender.

This is the only sender which does not FEC-encode the stream. This is not necessary because HTTP sits on top of TCP, a reliable transport which retransmits lost packets automatically. The sender employs per-client queues which queue chunks of audio data if they can not be sent immediately because the write operation would block. Most methods of the sender are implemented as wrappers for the generic functions defined in send_common.c.

◆ senders

const struct sender* const senders[]
Initial value:

NULL-terminated list, defined in vss.c.

Referenced by vss_shutdown().

http_sender
const struct sender udp_sender dccp_sender http_sender
The HTTP sender.
Definition: http_send.c:273
dccp_sender
const struct sender dccp_sender
The DCCP sender.
Definition: dccp_send.c:258
udp_sender
const struct sender udp_sender
The UDP sender.
Definition: udp_send.c:448