Fork me on GitHub
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
record.h File Reference

Audio/Video recorder. More...

#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "mutex.h"
#include "refcount.h"
#include "rtp.h"
Include dependency graph for record.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  janus_recorder
 Structure that represents a recorder. More...
 

Typedefs

typedef enum janus_recorder_medium janus_recorder_medium
 Media types we can record.
 
typedef struct janus_recorder janus_recorder
 Structure that represents a recorder.
 

Enumerations

enum  janus_recorder_medium { JANUS_RECORDER_AUDIO , JANUS_RECORDER_VIDEO , JANUS_RECORDER_DATA }
 Media types we can record. More...
 

Functions

void janus_recorder_init (gboolean tempnames, const char *extension)
 Initialize the recorder code.
 
void janus_recorder_deinit (void)
 De-initialize the recorder code.
 
janus_recorderjanus_recorder_create (const char *dir, const char *codec, const char *filename)
 Create a new recorder.
 
janus_recorderjanus_recorder_create_full (const char *dir, const char *codec, const char *fmtp, const char *filename)
 Create a new recorder with additional info.
 
int janus_recorder_pause (janus_recorder *recorder)
 Pause recording packets.
 
int janus_recorder_resume (janus_recorder *recorder)
 Resume recording packets.
 
int janus_recorder_add_extmap (janus_recorder *recorder, int id, const char *extmap)
 Add an RTP extension to this recording.
 
int janus_recorder_opusred (janus_recorder *recorder, int red_pt)
 Mark this recording as using RED for audio.
 
int janus_recorder_encrypted (janus_recorder *recorder)
 Mark this recorder as end-to-end encrypted (e.g., via Insertable Streams)
 
int janus_recorder_save_frame (janus_recorder *recorder, char *buffer, uint length)
 Save an RTP frame in the recorder.
 
int janus_recorder_close (janus_recorder *recorder)
 Close the recorder.
 
void janus_recorder_destroy (janus_recorder *recorder)
 Destroy the recorder instance.
 

Detailed Description

Audio/Video recorder.

Audio/Video recorder (headers)

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation of a simple recorder utility that plugins can make use of to record audio/video frames to a Janus file. This file just saves RTP frames in a structured way, so that they can be post-processed later on to get a valid container file (e.g., a .opus file for Opus audio or a .webm file for VP8 video) and keep things simpler on the plugin and core side. Check the Recordings documentation for more details.

Note
If you want to record both audio and video, you'll have to use two different recorders. Any muxing in the same container will have to be done in the post-processing phase.

Core

Typedef Documentation

◆ janus_recorder

typedef struct janus_recorder janus_recorder

Structure that represents a recorder.

◆ janus_recorder_medium

Media types we can record.

Enumeration Type Documentation

◆ janus_recorder_medium

Media types we can record.

Enumerator
JANUS_RECORDER_AUDIO 
JANUS_RECORDER_VIDEO 
JANUS_RECORDER_DATA 

Function Documentation

◆ janus_recorder_add_extmap()

int janus_recorder_add_extmap ( janus_recorder * recorder,
int id,
const char * extmap )

Add an RTP extension to this recording.

Note
This will only be possible BEFORE the first frame is written, as it needs to be reflected in the .mjr header: doing this after that will return an error.
Parameters
[in]recorderThe janus_recorder instance to add the extension to
[in]idNumeric ID of the RTP extension
[in]extmapNamespace of the RTP extension
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_close()

int janus_recorder_close ( janus_recorder * recorder)

Close the recorder.

Parameters
[in]recorderThe janus_recorder instance to close
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_create()

janus_recorder * janus_recorder_create ( const char * dir,
const char * codec,
const char * filename )

Create a new recorder.

Note
If no target directory is provided, the current directory will be used. If no filename is passed, a random filename will be used.
Parameters
[in]dirPath of the directory to save the recording into (will try to create it if it doesn't exist)
[in]codecCodec the packets to record are encoded in ("vp8", "opus", "h264", "g711", "vp9")
[in]filenameFilename to use for the recording
Returns
A valid janus_recorder instance in case of success, NULL otherwise

◆ janus_recorder_create_full()

janus_recorder * janus_recorder_create_full ( const char * dir,
const char * codec,
const char * fmtp,
const char * filename )

Create a new recorder with additional info.

Note
This is to allow adding more arguments to janus_recorder_create, but still keep janus_recorder_create in place for backwards compatibility.
Parameters
[in]dirPath of the directory to save the recording into (will try to create it if it doesn't exist)
[in]codecCodec the packets to record are encoded in ("vp8", "opus", "h264", "g711", "vp9")
[in]fmtpCodec-specific details (e.g., the H.264 or VP9 profile)
[in]filenameFilename to use for the recording
Returns
A valid janus_recorder instance in case of success, NULL otherwise

◆ janus_recorder_deinit()

void janus_recorder_deinit ( void )

De-initialize the recorder code.

◆ janus_recorder_destroy()

void janus_recorder_destroy ( janus_recorder * recorder)

Destroy the recorder instance.

Parameters
[in]recorderThe janus_recorder instance to destroy

◆ janus_recorder_encrypted()

int janus_recorder_encrypted ( janus_recorder * recorder)

Mark this recorder as end-to-end encrypted (e.g., via Insertable Streams)

Note
This will only be possible BEFORE the first frame is written, as it needs to be reflected in the .mjr header: doing this after that will return an error. Also notice that an encrypted recording will NOT be processable with janus-pp-rec out of the box, since the post-processor will not have access to unencrypted media
Parameters
[in]recorderThe janus_recorder instance to mark as encrypted
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_init()

void janus_recorder_init ( gboolean tempnames,
const char * extension )

Initialize the recorder code.

Parameters
[in]tempnamesWhether the filenames should have a temporary extension, while saving, or not
[in]extensionExtension to add in case tempnames is true

◆ janus_recorder_opusred()

int janus_recorder_opusred ( janus_recorder * recorder,
int red_pt )

Mark this recording as using RED for audio.

Note
This will only be possible BEFORE the first frame is written, as it needs to be reflected in the .mjr header: doing this after that will return an error.
Parameters
[in]recorderThe janus_recorder instance to configure
[in]red_ptPayload type of RED
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_pause()

int janus_recorder_pause ( janus_recorder * recorder)

Pause recording packets.

Note
This is to allow pause and resume recorder functionality.
Parameters
[in]recorderThe janus_recorder to pause
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_resume()

int janus_recorder_resume ( janus_recorder * recorder)

Resume recording packets.

Note
This is to allow pause and resume recorder functionality.
Parameters
[in]recorderThe janus_recorder to resume
Returns
0 in case of success, a negative integer otherwise

◆ janus_recorder_save_frame()

int janus_recorder_save_frame ( janus_recorder * recorder,
char * buffer,
uint length )

Save an RTP frame in the recorder.

Parameters
[in]recorderThe janus_recorder instance to save the frame to
[in]bufferThe frame data to save
[in]lengthThe frame data length
Returns
0 in case of success, a negative integer otherwise