Blender V4.3
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
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "BKE_packedFile.hh"
15
16#include "rna_internal.hh"
17
18#ifdef RNA_RUNTIME
19
20static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports)
21{
23 reports, sound->filepath, ID_BLEND_PATH(bmain, &sound->id));
24}
25
26static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, int method)
27{
28 if (!sound->packedfile) {
29 BKE_report(reports, RPT_ERROR, "Sound not packed");
30 return;
31 }
32
33 if (!ID_IS_EDITABLE(&sound->id)) {
34 BKE_report(reports, RPT_ERROR, "Sound is not editable");
35 return;
36 }
37
38 /* reports its own error on failure */
39 BKE_packedfile_unpack_sound(bmain, reports, sound, ePF_FileStatus(method));
40}
41
42#else
43
45{
46 FunctionRNA *func;
47
48 func = RNA_def_function(srna, "pack", "rna_Sound_pack");
49 RNA_def_function_ui_description(func, "Pack the sound into the current blend file");
51
52 func = RNA_def_function(srna, "unpack", "rna_Sound_unpack");
53 RNA_def_function_ui_description(func, "Unpack the sound to the samples filename");
56 func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
57}
58
59#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
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
#define ID_BLEND_PATH(_bmain, _id)
Definition DNA_ID.h:647
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:658
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
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]