Audacity 3.2.0
MixdownUploader.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 MixdownUploader.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#pragma once
12
13#include <atomic>
14#include <cstdint>
15#include <condition_variable>
16#include <functional>
17#include <future>
18#include <memory>
19#include <mutex>
20#include <optional>
21#include <string>
22
23#include "CloudSyncDTO.h"
24
25#include "NetworkUtils.h"
26
29
30class AudacityProject;
31
33{
34class ServiceConfig;
35}
36
38{
39
40enum class MixdownState : uint32_t
41{
46 Cancelled,
47 Failed,
48 Empty,
49};
50
51struct CLOUD_AUDIOCOM_API MixdownResult final
52{
55};
56
57using MixdownProgressCallback = std::function<void(double progress)>;
58
59class CLOUD_AUDIOCOM_API MixdownUploader final :
60 public std::enable_shared_from_this<MixdownUploader>,
62{
63 struct Tag final
64 {
65 };
66
67public:
69 Tag, concurrency::CancellationContextPtr cancellationContext,
70 const ServiceConfig& config, const AudacityProject& project,
71 MixdownProgressCallback progressCallback);
72
74
75 static std::shared_ptr<MixdownUploader> Upload(
76 concurrency::CancellationContextPtr cancellationContext,
77 const ServiceConfig& config, const AudacityProject& project,
78 MixdownProgressCallback progressCallback);
79
80 void SetUrls(const UploadUrls& urls);
81
82 std::future<MixdownResult> GetResultFuture();
83
84private:
85 void Cancel();
86
87 void ReportProgress(
88 MixdownState state, double progress, ResponseResult uploadResult);
89 void ExportProject();
90 void UploadMixdown();
91
94
95 std::mutex mUploadUrlsMutex;
96 std::condition_variable mUploadUrlsSet;
97 std::optional<UploadUrls> mUploadUrls;
98
100
101 class DataExporter;
102 std::unique_ptr<DataExporter> mDataExporter;
103
104 std::string mExportedFilePath;
105
106 std::atomic<double> mProgress {};
107
108 bool mProgressUpdateQueued { false };
109
110 std::atomic<bool> mUploadCancelled { false };
111 std::atomic<bool> mFinished { false };
112
113 std::promise<MixdownResult> mPromise;
114
116}; // class MixdownUploader
117} // namespace audacity::cloud::audiocom::sync
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Configuration for the audio.com.
Definition: ServiceConfig.h:23
std::unique_ptr< DataExporter > mDataExporter
concurrency::CancellationContextPtr mCancellationContext
void UploadMixdown(AudacityProject &project, std::function< void(AudacityProject &, MixdownState)> onComplete)
std::function< void(double progress)> MixdownProgressCallback
std::shared_ptr< CancellationContext > CancellationContextPtr