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