libnx v4.9.0
Loading...
Searching...
No Matches
capsc.h
Go to the documentation of this file.
1/**
2 * @file capsc.h
3 * @brief Album Control (caps:c) service IPC wrapper.
4 * @author Behemoth
5 * @copyright libnx Authors
6 */
7#pragma once
8#include "../types.h"
9#include "../sf/service.h"
10#include "../services/caps.h"
11
12typedef struct {
13 u64 application_id;
14 u8 unknown_08;
15 u8 unknown_09;
16 u8 reserved[6];
18
19/// Initialize caps:c
21
22/// Exit caps:c.
23void capscExit(void);
24
25/// Gets the Service for caps:c.
27
28/**
29 * @brief Notify the service that a storage is now available.
30 * @note This will result in capsrv mounting the image directory on that storage medium.
31 * @param[in] storage \ref CapsAlbumStorage
32 */
34
35/**
36 * @brief Notify the service that a storage is now unavailable.
37 * @note This will result in capsrv unmounting the image directory on that storage medium.
38 * @param[in] storage \ref CapsAlbumStorage
39 */
41
42/**
43 * @brief Register an applet for later usage.
44 * @note Called at application launch by the system.
45 * @note Will generate a random AES-256 key for this application for use on Shim-Version 0.
46 * @note Only available on [2.0.0+].
47 * @param[in] appletResourceUserId AppletResourceUserId.
48 * @param[in] application_id ApplicationId.
49 */
50Result capscRegisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id);
51
52/**
53 * @brief Unregister an applet.
54 * @note Called at application exit by the system.
55 * @note Only available on [2.0.0+].
56 * @param[in] appletResourceUserId AppletResourceUserId.
57 * @param[in] application_id ApplicationId.
58 */
59Result capscUnregisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id);
60
61/**
62 * @brief Get an ApplicationId that corresponds to an AppletResourceUserId.
63 * @note Returns value set by \ref capscRegisterAppletResourceUserId.
64 * @note Only available on [2.0.0+].
65 * @param[out] application_id ApplicationId.
66 * @param[in] appletResourceUserId AppletResourceUserId.
67 */
69
70/**
71 * @brief Checks whether an ApplicationId is registered.
72 * @note Only available on [2.0.0+].
73 * @param[in] application_id ApplicationId.
74 */
76
77/**
78 * @brief Generate an AlbumFileId based on parameters and current time.
79 * @param[in] application_id ApplicationId.
80 * @note Only available on [2.0.0+].
81 * @param[in] contents \ref CapsAlbumFileContents
82 * @param[out] file_id \ref CapsAlbumFileId
83 */
85
86/**
87 * @brief Generate an ApplicationAlbumEntry based on parameters.
88 * @note Output will be different between Shim Version 0 and 1.
89 * @note Only available on [2.0.0+].
90 * @param[out] appEntry \ref CapsApplicationAlbumEntry
91 * @param[in] entry \ref CapsAlbumEntry
92 * @param[in] application_id ApplicationId.
93 */
95
96/**
97 * @brief Save a jpeg image.
98 * @note Only available on [2.0.0-3.0.2].
99 * @param[in] file_id \ref CapsAlbumFileId
100 * @param[in] buffer JPEG image buffer.
101 * @param[in] buffer_size Size of the JPEG image.
102 */
103Result capscSaveAlbumScreenShotFile(const CapsAlbumFileId *file_id, const void* buffer, u64 buffer_size);
104
105/**
106 * @brief Save a jpeg image.
107 * @note Only available on [4.0.0+].
108 * @note Version 3 as of [9.1.0].
109 * @param[in] file_id \ref CapsAlbumFileId
110 * @param[in] version Revision number.
111 * @param[in] makernote_offset Offset to makernote in JPEG buffer.
112 * @param[in] makernote_size Size of the makernote in JPEG buffer.
113 * @param[in] buffer JPEG image buffer.
114 * @param[in] buffer_size Size of the JPEG image.
115 */
116Result capscSaveAlbumScreenShotFileEx(const CapsAlbumFileId *file_id, u64 version, u64 makernote_offset, u64 makernote_size, const void* buffer, u64 buffer_size);
117
118/**
119 * @brief Sets thumbnail data for the last taken screenshot.
120 * @note 96×54 Image will get saved.
121 * @param[in] file_id \ref CapsAlbumFileId
122 * @param[in] image RGBA8 image buffer.
123 * @param[in] image_size size of the RGBA8 image buffer.
124 */
125Result capscSetOverlayScreenShotThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size);
126
127/**
128 * @brief Sets thumbnail data for the last recorded movie.
129 * @note Only availabe on [4.0.0+].
130 * @note 96×54 Image will get saved.
131 * @param[in] file_id \ref CapsAlbumFileId
132 * @param[in] image RGBA8 image buffer.
133 * @param[in] image_size size of the RGBA8 image buffer.
134 */
135Result capscSetOverlayMovieThumbnailData(const CapsAlbumFileId *file_id, const void* image, u64 image_size);
136
137/**
138 * @brief Opens an AlbumMovieReadStream.
139 * @note This opens IAlbumControlSession if not previously opened, it's closed during \ref capscExit.
140 * @note Up to 4 streams can be open at the same time. Multiple streams can be open at the same time for the same \ref CapsAlbumFileId.
141 * @note Only available on [4.0.0+].
142 * @param[out] stream Stream handle.
143 * @param[in] entry \ref CapsAlbumFileId
144 */
146
147/**
148 * @brief Closes an AlbumMovieReadStream.
149 * @note Only available on [4.0.0+].
150 * @param[in] stream Stream handle.
151 */
153
154/**
155 * @brief Gets the data size of an AlbumMovieReadStream.
156 * @note Only available on [4.0.0+].
157 * @param[in] stream Stream handle.
158 * @param[out] size Size of the actual MP4, without the JPEG at the end.
159 */
161
162/**
163 * @brief Reads data from an AlbumMovieReadStream.
164 * @note offset(+size) must not be negative. offset and size must be aligned to 0x40000-bytes.
165 * @note When offset(+size) goes beyond the size from \ref capscGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
166 * @note Only available on [4.0.0+].
167 * @param[in] stream Stream handle.
168 * @param[in] offset Offset.
169 * @param[out] Output data buffer.
170 * @param[in] size Data buffer size.
171 * @param[out] actual_size Actual read size.
172 */
173Result capscReadMovieDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size);
174
175/**
176 * @brief Gets the BrokenReason for an AlbumMovieReadStream.
177 * @note Official sw doesn't use this.
178 * @note Only available on [4.0.0+].
179 * @param[in] stream Stream handle.
180 */
182
183/**
184 * @brief Gets the data size of an Image taken from an AlbumMovieReadStream.
185 * @note Only available on [4.0.0+].
186 * @param[in] stream Stream handle.
187 * @param[out] size Expected size of an Image.
188 */
190
191/**
192 * @brief Reads data of an Image taken from an AlbumMovieReadStream.
193 * @note Only available on [4.0.0+].
194 * @param[in] stream Stream handle.
195 * @param[in] offset Offset.
196 * @param[out] buffer Output data buffer.
197 * @param[in] size Data buffer size.
198 * @param[out] actual_size Actual read size.
199 */
200Result capscReadImageDataFromAlbumMovieReadStream(u64 stream, u64 offset, void* buffer, size_t size, u64 *actual_size);
201
202/**
203 * @brief Gets the file attribute of an AlbumMovieReadStream.
204 * @note Only available on [4.0.0+].
205 * @param[in] stream Stream handle.
206 * @param[out] attr \ref CapsScreenShotAttribute
207 */
209
210/**
211 * @brief Opens an AlbumMovieWriteStream.
212 * @note This opens IAlbumControlSession if not previously opened, it's closed during \ref capsaExit.
213 * @note Up to 2 streams can be open at the same time.
214 * @note Only available on [4.0.0+].
215 * @param[out] stream Stream handle.
216 * @param[in] entry \ref CapsAlbumFileId
217 */
219
220/**
221 * @brief Finish write to AlbumMovieWriteStream.
222 * @note Copies file from save to destination storage and deletes the temporary file.
223 * @note Only available on [4.0.0+].
224 * @param[in] stream Stream handle.
225 */
227
228/**
229 * @brief Closes a finished AlbumMovieWriteStream.
230 * @note Only available on [4.0.0+].
231 * @param[in] stream Stream handle.
232 */
234
235/**
236 * @brief Closes an AlbumMovieWriteStream in any state.
237 * @note Only available on [4.0.0+].
238 * @param[in] stream Stream handle.
239 */
241
242/**
243 * @brief Closes an AlbumMovieWriteStream in any state without deleting the temporary file.
244 * @note Only available on [4.0.0+].
245 * @param[in] stream Stream handle.
246 */
248
249/**
250 * @brief Closes a finished AlbumMovieWriteStream.
251 * @note Only available on [4.0.0+].
252 * @param[in] stream Stream handle.
253 * @param[out] entry \ref CapsAlbumEntry
254 */
256
257/**
258 * @brief Start AlbumMovieWriteStream data section.
259 * @note Only available on [4.0.0+].
260 * @param[in] stream Stream handle.
261 */
263
264/**
265 * @brief End AlbumMovieWriteStream data section.
266 * @note Only available on [4.0.0+].
267 * @param[in] stream Stream handle.
268 */
270
271/**
272 * @brief Start AlbumMovieWriteStream meta section.
273 * @note Only available on [4.0.0+].
274 * @param[in] stream Stream handle.
275 */
277
278/**
279 * @brief End AlbumMovieWriteStream meta section.
280 * @note Only available on [4.0.0+].
281 * @param[in] stream Stream handle.
282 */
284
285/**
286 * @brief Reads data from an AlbumMovieWriteStream.
287 * @note offset(+size) must not be negative. offset and size must be aligned to 0x40000-bytes.
288 * @note When offset(+size) goes beyond the size from \ref capscGetAlbumMovieStreamSize, the regions of the buffer which goes beyond that are cleared to 0, and actual_size is still set to the input size.
289 * @note Only available on [4.0.0+].
290 * @param[in] stream Stream handle.
291 * @param[in] offset Offset.
292 * @param[out] buffer Output data buffer.
293 * @param[in] size Data buffer size.
294 * @param[out] actual_size Actual read size.
295 */
296Result capscReadDataFromAlbumMovieWriteStream(u64 stream, u64 offset, void* buffer, u64 size, u64 *actual_size);
297
298/**
299 * @brief Write data to an AlbumMovieWriteStream.
300 * @note Only available on [4.0.0+].
301 * @param[in] stream Stream handle.
302 * @param[in] offset Offset.
303 * @param[in] buffer Input data buffer.
304 * @param[in] size Data buffer size.
305 */
306Result capscWriteDataToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size);
307
308/**
309 * @brief Write meta data to an AlbumMovieWriteStream.
310 * @note Only available on [4.0.0+].
311 * @param[in] stream Stream handle.
312 * @param[in] offset Offset.
313 * @param[in] buffer Input data buffer.
314 * @param[in] size Data buffer size.
315 */
316Result capscWriteMetaToAlbumMovieWriteStream(u64 stream, u64 offset, const void* buffer, u64 size);
317
318/**
319 * @brief Gets the BrokenReason for an AlbumMovieWriteStream.
320 * @note Only available on [4.0.0+].
321 * @param[in] stream Stream handle.
322 */
324
325/**
326 * @brief Gets the data size of an AlbumMovieWriteStream.
327 * @note Only available on [4.0.0+].
328 * @param[in] stream Stream handle.
329 * @param[out] size Size of the data section.
330 */
332
333/**
334 * @brief Sets the data size of an AlbumMovieWriteStream.
335 * @note Must not be bigger than 2GiB.
336 * @note Only available on [4.0.0+].
337 * @param[in] stream Stream handle.
338 * @param[out] size Size of the data section.
339 */
CapsAlbumFileContents
AlbumFileContents.
Definition caps.h:142
CapsAlbumStorage
Definition caps.h:25
Result capscWriteDataToAlbumMovieWriteStream(u64 stream, u64 offset, const void *buffer, u64 size)
Write data to an AlbumMovieWriteStream.
Result capscGenerateCurrentAlbumFileId(const CapsApplicationId *application_id, CapsAlbumFileContents contents, CapsAlbumFileId *file_id)
Generate an AlbumFileId based on parameters and current time.
Result capscInitialize(void)
Initialize caps:c.
Result capscRegisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id)
Register an applet for later usage.
Result capscSetOverlayScreenShotThumbnailData(const CapsAlbumFileId *file_id, const void *image, u64 image_size)
Sets thumbnail data for the last taken screenshot.
Result capscEndAlbumMovieWriteStreamMetaSection(u64 stream)
End AlbumMovieWriteStream meta section.
Result capscGetAlbumMovieReadStreamImageDataSize(u64 stream, u64 *size)
Gets the data size of an Image taken from an AlbumMovieReadStream.
Result capscCommitAlbumMovieWriteStream(u64 stream)
Closes a finished AlbumMovieWriteStream.
void capscExit(void)
Exit caps:c.
Result capscReadDataFromAlbumMovieWriteStream(u64 stream, u64 offset, void *buffer, u64 size, u64 *actual_size)
Reads data from an AlbumMovieWriteStream.
Result capscWriteMetaToAlbumMovieWriteStream(u64 stream, u64 offset, const void *buffer, u64 size)
Write meta data to an AlbumMovieWriteStream.
Result capscEndAlbumMovieWriteStreamDataSection(u64 stream)
End AlbumMovieWriteStream data section.
Result capscReadMovieDataFromAlbumMovieReadStream(u64 stream, u64 offset, void *buffer, size_t size, u64 *actual_size)
Reads data from an AlbumMovieReadStream.
Service * capscGetServiceSession(void)
Gets the Service for caps:c.
Result capscOpenAlbumMovieReadStream(u64 *stream, const CapsAlbumFileId *file_id)
Opens an AlbumMovieReadStream.
Result capscCheckApplicationIdRegistered(u64 application_id)
Checks whether an ApplicationId is registered.
Result capscNotifyAlbumStorageIsAvailable(CapsAlbumStorage storage)
Notify the service that a storage is now available.
Result capscDiscardAlbumMovieWriteStream(u64 stream)
Closes an AlbumMovieWriteStream in any state.
Result capscGetApplicationIdFromAruid(CapsApplicationId *application_id, u64 aruid)
Get an ApplicationId that corresponds to an AppletResourceUserId.
Result capscSaveAlbumScreenShotFileEx(const CapsAlbumFileId *file_id, u64 version, u64 makernote_offset, u64 makernote_size, const void *buffer, u64 buffer_size)
Save a jpeg image.
Result capscStartAlbumMovieWriteStreamDataSection(u64 stream)
Start AlbumMovieWriteStream data section.
Result capscNotifyAlbumStorageIsUnAvailable(CapsAlbumStorage storage)
Notify the service that a storage is now unavailable.
Result capscSetAlbumMovieWriteStreamDataSize(u64 stream, u64 size)
Sets the data size of an AlbumMovieWriteStream.
Result capscGetAlbumMovieWriteStreamBrokenReason(u64 stream)
Gets the BrokenReason for an AlbumMovieWriteStream.
Result capscSetOverlayMovieThumbnailData(const CapsAlbumFileId *file_id, const void *image, u64 image_size)
Sets thumbnail data for the last recorded movie.
Result capscCloseAlbumMovieStream(u64 stream)
Closes an AlbumMovieReadStream.
Result capscGetAlbumMovieWriteStreamDataSize(u64 stream, u64 *size)
Gets the data size of an AlbumMovieWriteStream.
Result capscReadImageDataFromAlbumMovieReadStream(u64 stream, u64 offset, void *buffer, size_t size, u64 *actual_size)
Reads data of an Image taken from an AlbumMovieReadStream.
Result capscGetAlbumMovieStreamSize(u64 stream, u64 *size)
Gets the data size of an AlbumMovieReadStream.
Result capscFinishAlbumMovieWriteStream(u64 stream)
Finish write to AlbumMovieWriteStream.
Result capscStartAlbumMovieWriteStreamMetaSection(u64 stream)
Start AlbumMovieWriteStream meta section.
Result capscOpenAlbumMovieWriteStream(u64 *stream, const CapsAlbumFileId *file_id)
Opens an AlbumMovieWriteStream.
Result capscCommitAlbumMovieWriteStreamEx(u64 stream, CapsAlbumEntry *entry)
Closes a finished AlbumMovieWriteStream.
Result capscDiscardAlbumMovieWriteStreamNoDelete(u64 stream)
Closes an AlbumMovieWriteStream in any state without deleting the temporary file.
Result capscReadFileAttributeFromAlbumMovieReadStream(u64 stream, CapsScreenShotAttribute *attribute)
Gets the file attribute of an AlbumMovieReadStream.
Result capscUnregisterAppletResourceUserId(u64 appletResourceUserId, const CapsApplicationId *application_id)
Unregister an applet.
Result capscGenerateApplicationAlbumEntry(CapsApplicationAlbumEntry *appEntry, const CapsAlbumEntry *entry, u64 application_id)
Generate an ApplicationAlbumEntry based on parameters.
Result capscGetAlbumMovieReadStreamBrokenReason(u64 stream)
Gets the BrokenReason for an AlbumMovieReadStream.
Result capscSaveAlbumScreenShotFile(const CapsAlbumFileId *file_id, const void *buffer, u64 buffer_size)
Save a jpeg image.
AlbumEntry.
Definition caps.h:102
AlbumEntryId.
Definition caps.h:91
ApplicationAlbumEntry.
Definition caps.h:108
Definition capsc.h:12
ScreenShotAttribute.
Definition caps.h:38
Service object structure.
Definition service.h:14
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
uint8_t u8
8-bit unsigned integer.
Definition types.h:19
u32 Result
Function error code result type.
Definition types.h:44