Blender V5.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
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
18# include "DNA_sound_types.h"
19
20# include "BKE_library.hh"
21# include "BKE_main.hh"
22# include "BKE_report.hh"
23# include "BKE_sound.hh"
24
25namespace blender {
26
27static void rna_Sound_pack(bSound *sound, Main *bmain, ReportList *reports)
28{
29 BKE_sound_packfile_ensure(bmain, sound, reports);
30}
31
32static void rna_Sound_unpack(bSound *sound, Main *bmain, ReportList *reports, int method)
33{
34 if (!sound->packedfile) {
35 BKE_report(reports, RPT_ERROR, "Sound not packed");
36 return;
37 }
38
39 if (!ID_IS_EDITABLE(&sound->id)) {
40 BKE_report(reports, RPT_ERROR, "Sound is not editable");
41 return;
42 }
43
44 /* reports its own error on failure */
45 BKE_packedfile_unpack_sound(bmain, reports, sound, ePF_FileStatus(method));
46}
47
48} // namespace blender
49
50#else
51
52namespace blender {
53
55{
56 FunctionRNA *func;
57
58 func = RNA_def_function(srna, "pack", "rna_Sound_pack");
59 RNA_def_function_ui_description(func, "Pack the sound into the current blend file");
61
62 func = RNA_def_function(srna, "unpack", "rna_Sound_unpack");
63 RNA_def_function_ui_description(func, "Unpack the sound to the samples filename");
66 func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
67}
68
69} // namespace blender
70
71#endif
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
BMesh Iterators.
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
@ FUNC_USE_REPORTS
@ FUNC_USE_MAIN
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_api_sound(StructRNA *srna)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void BKE_sound_packfile_ensure(Main *bmain, bSound *sound, ReportList *reports)
const EnumPropertyItem rna_enum_unpack_method_items[]
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, enum ePF_FileStatus how)