Blender V5.0
rna_sound_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "RNA_define.hh"
10#include "RNA_enum_types.hh"
11
12#include "BKE_packedFile.hh"
13
14#include "rna_internal.hh"
15
16#ifdef RNA_RUNTIME
17
18static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports)
19{
21 reports, sound->filepath, ID_BLEND_PATH(bmain, &sound->id));
22}
23
24static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, int method)
25{
26 if (!sound->packedfile) {
27 BKE_report(reports, RPT_ERROR, "Sound not packed");
28 return;
29 }
30
31 if (!ID_IS_EDITABLE(&sound->id)) {
32 BKE_report(reports, RPT_ERROR, "Sound is not editable");
33 return;
34 }
35
36 /* reports its own error on failure */
37 BKE_packedfile_unpack_sound(bmain, reports, sound, ePF_FileStatus(method));
38}
39
40#else
41
43{
44 FunctionRNA *func;
45
46 func = RNA_def_function(srna, "pack", "rna_Sound_pack");
47 RNA_def_function_ui_description(func, "Pack the sound into the current blend file");
49
50 func = RNA_def_function(srna, "unpack", "rna_Sound_unpack");
51 RNA_def_function_ui_description(func, "Unpack the sound to the samples filename");
54 func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
55}
56
57#endif
int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, enum ePF_FileStatus how)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath)
ePF_FileStatus
@ PF_USE_LOCAL
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
#define ID_BLEND_PATH(_bmain, _id)
Definition DNA_ID.h:685
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:705
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
const EnumPropertyItem rna_enum_unpack_method_items[]
void RNA_api_sound(StructRNA *srna)
struct PackedFile * packedfile
char filepath[1024]