libnx  v4.8.0
Data Structures | Macros | Enumerations
grc.h File Reference

GRC Game Recording (grc:*) service IPC wrapper. More...

#include "../types.h"
#include "../sf/service.h"
#include "../services/caps.h"
#include "../kernel/event.h"
#include "../kernel/tmem.h"
#include "../display/native_window.h"

Go to the source code of this file.

Data Structures

struct  GrcGameMovieTrimmer
 GameMovieTrimmer. More...
 
struct  GrcMovieMaker
 IMovieMaker. More...
 
struct  GrcGameMovieId
 GameMovieId. More...
 
struct  GrcOffscreenRecordingParameter
 OffscreenRecordingParameter. More...
 

Macros

#define GRC_MOVIEMAKER_WORKMEMORY_SIZE_DEFAULT   0x6000000
 Default size for grcCreateMovieMaker, this is the size used by official sw.
 

Enumerations

enum  GrcStream {
  GrcStream_Video = 0 ,
  GrcStream_Audio = 1
}
 Stream type values for grcdTransfer. More...
 

Functions

Trimming
Result grcTrimGameMovie (GrcGameMovieId *dst_movieid, const GrcGameMovieId *src_movieid, size_t tmem_size, const void *thumbnail, s32 start, s32 end)
 Creates a GrcGameMovieTrimmer using appletCreateGameMovieTrimmer, uses the cmds from it to trim the specified video, then closes it. More...
 
IMovieMaker
void grcCreateOffscreenRecordingParameter (GrcOffscreenRecordingParameter *param)
 Creates a GrcOffscreenRecordingParameter with the default values, see GrcOffscreenRecordingParameter for the default values. More...
 
Result grcCreateMovieMaker (GrcMovieMaker *m, size_t size)
 Creates a GrcMovieMaker using appletCreateMovieMaker, and does the required initialization. More...
 
void grcMovieMakerClose (GrcMovieMaker *m)
 Closes a GrcMovieMaker. More...
 
static NWindowgrcMovieMakerGetNWindow (GrcMovieMaker *m)
 Gets the NWindow for the specified MovieMaker. More...
 
Result grcMovieMakerAbort (GrcMovieMaker *m)
 Aborts recording with the specified MovieMaker. More...
 
Result grcMovieMakerStart (GrcMovieMaker *m, const GrcOffscreenRecordingParameter *param)
 Starts recording with the specified MovieMaker and GrcOffscreenRecordingParameter. More...
 
Result grcMovieMakerFinish (GrcMovieMaker *m, s32 width, s32 height, const void *userdata, size_t userdata_size, const void *thumbnail, size_t thumbnail_size, CapsApplicationAlbumEntry *entry)
 Finishes recording with the specified MovieMaker. More...
 
Result grcMovieMakerGetError (GrcMovieMaker *m)
 Gets the recording error with the specified MovieMaker. More...
 
Result grcMovieMakerEncodeAudioSample (GrcMovieMaker *m, const void *buffer, size_t size)
 Encodes audio sample data with the specified MovieMaker. More...
 
grc:d
Result grcdInitialize (void)
 Initialize grc:d.
 
void grcdExit (void)
 Exit grc:d.
 
ServicegrcdGetServiceSession (void)
 Gets the Service for grc:d.
 
Result grcdBegin (void)
 Begins streaming. This must not be called more than once, even from a different service session: otherwise the sysmodule will assert.
 
Result grcdTransfer (GrcStream stream, void *buffer, size_t size, u32 *num_frames, u32 *data_size, u64 *start_timestamp)
 Retrieves stream data from the continuous recorder in use (from the video recording of the currently running application). More...
 

Detailed Description

GRC Game Recording (grc:*) service IPC wrapper.

Author
yellows8

Enumeration Type Documentation

◆ GrcStream

enum GrcStream

Stream type values for grcdTransfer.

Enumerator
GrcStream_Video 

Video stream with H.264 NAL units. Official sw uses buffer size 0x32000.

GrcStream_Audio 

Audio stream with PcmFormat_Int16, 2 channels, and samplerate = 48000Hz. Official sw uses buffer size 0x1000.

Function Documentation

◆ grcCreateMovieMaker()

Result grcCreateMovieMaker ( GrcMovieMaker m,
size_t  size 
)

Creates a GrcMovieMaker using appletCreateMovieMaker, and does the required initialization.

Note
See appletCreateMovieMaker for the requirements for using this.
Parameters
[out]mGrcMovieMaker
[in]sizeTransferMemory WorkMemory size. See GRC_MOVIEMAKER_WORKMEMORY_SIZE_DEFAULT.

◆ grcCreateOffscreenRecordingParameter()

void grcCreateOffscreenRecordingParameter ( GrcOffscreenRecordingParameter param)

Creates a GrcOffscreenRecordingParameter with the default values, see GrcOffscreenRecordingParameter for the default values.

Parameters
[out]paramGrcOffscreenRecordingParameter

◆ grcdTransfer()

Result grcdTransfer ( GrcStream  stream,
void *  buffer,
size_t  size,
u32 num_frames,
u32 data_size,
u64 start_timestamp 
)

Retrieves stream data from the continuous recorder in use (from the video recording of the currently running application).

Note
This will block until data is available. This will hang if there is no application running which has video capture enabled.
Parameters
[in]streamGrcStream
[out]bufferOutput buffer.
[in]sizeMax size of the output buffer.
[out]num_framesnum_frames
[out]data_sizeActual output data size.
[out]start_timestampStart timestamp.

◆ grcMovieMakerAbort()

Result grcMovieMakerAbort ( GrcMovieMaker m)

Aborts recording with the specified MovieMaker.

Note
This is used automatically by grcMovieMakerClose.
This will throw an error if grcMovieMakerStart was not used previously, with the flag used for this being cleared afterwards on success.
Parameters
mGrcMovieMaker

◆ grcMovieMakerClose()

void grcMovieMakerClose ( GrcMovieMaker m)

Closes a GrcMovieMaker.

Note
This also uses grcMovieMakerAbort.
Parameters
mGrcMovieMaker

◆ grcMovieMakerEncodeAudioSample()

Result grcMovieMakerEncodeAudioSample ( GrcMovieMaker m,
const void *  buffer,
size_t  size 
)

Encodes audio sample data with the specified MovieMaker.

Note
This waits on the event and uses the cmd repeatedly until the entire input buffer is handled.
If you don't use this the recorded video will be missing audio.
Parameters
mGrcMovieMaker
[in]bufferAudio buffer.
[in]sizeSize of the buffer.

◆ grcMovieMakerFinish()

Result grcMovieMakerFinish ( GrcMovieMaker m,
s32  width,
s32  height,
const void *  userdata,
size_t  userdata_size,
const void *  thumbnail,
size_t  thumbnail_size,
CapsApplicationAlbumEntry entry 
)

Finishes recording with the specified MovieMaker.

Note
This automatically uses grcMovieMakerAbort on error.
The recorded video will not be accessible via the Album-applet since it's stored separately from other Album data.
Parameters
mGrcMovieMaker
widthWidth for the thumbnail, must be 1280.
heightHeight for the thumbnail, must be 720.
[in]userdataUserData input buffer for the JPEG thumbnail. Optional, can be NULL.
[in]userdata_sizeSize of the UserData input buffer. Optional, can be 0. Must be <=0x400.
[in]thumbnailRGBA8 image buffer containing the thumbnail. Optional, can be NULL.
[in]thumbnail_sizeSize of the thumbnail buffer. Optional, can be 0.
[out]entryOutput CapsApplicationAlbumEntry for the recorded video. Optional, can be NULL. Only available on [7.0.0+], if this is not NULL on pre-7.0.0 an error is thrown.

◆ grcMovieMakerGetError()

Result grcMovieMakerGetError ( GrcMovieMaker m)

Gets the recording error with the specified MovieMaker.

Parameters
mGrcMovieMaker

◆ grcMovieMakerGetNWindow()

static NWindow* grcMovieMakerGetNWindow ( GrcMovieMaker m)
inlinestatic

Gets the NWindow for the specified MovieMaker.

Parameters
mGrcMovieMaker

◆ grcMovieMakerStart()

Result grcMovieMakerStart ( GrcMovieMaker m,
const GrcOffscreenRecordingParameter param 
)

Starts recording with the specified MovieMaker and GrcOffscreenRecordingParameter.

Parameters
mGrcMovieMaker
[in]paramGrcOffscreenRecordingParameter

◆ grcTrimGameMovie()

Result grcTrimGameMovie ( GrcGameMovieId dst_movieid,
const GrcGameMovieId src_movieid,
size_t  tmem_size,
const void *  thumbnail,
s32  start,
s32  end 
)

Creates a GrcGameMovieTrimmer using appletCreateGameMovieTrimmer, uses the cmds from it to trim the specified video, then closes it.

Note
See appletCreateGameMovieTrimmer for the requirements for using this.
This will block until video trimming finishes.
Parameters
[out]dst_movieidGrcGameMovieId for the output video.
[in]src_movieidGrcGameMovieId for the input video.
[in]tmem_sizeTransferMemory size. Official sw uses size 0x2000000.
[in]thumbnailOptional, can be NULL. RGBA8 1280x720 thumbnail image data.
[in]startStart timestamp in 0.5s units.
[in]endEnd timestamp in 0.5s units.