Audacity 3.2.0
Public Member Functions | List of all members
cloud::audiocom::ServiceConfig Class Referencefinal

Configuration for the audio.com. More...

#include <ServiceConfig.h>

Public Member Functions

std::string_view GetAPIEndpoint () const
 API endpoint. More...
 
std::string_view GetOAuthLoginPage () const
 Page to open in browser to initiate OAuth. More...
 
std::string_view GetOAuthClientID () const
 OAuth2 client ID. More...
 
std::string_view GetOAuthRedirectURL () const
 OAuth2 redirect URL. Only used to satisfy the protocol. More...
 
std::string GetAPIUrl (std::string_view apiURI) const
 Helper to construct the full URLs for the API. More...
 
std::string GetFinishUploadPage (std::string_view audioID, std::string_view token) const
 Helper to construct the page URL for the anonymous upload last stage. More...
 
std::string GetAudioURL (std::string_view userSlug, std::string_view audioSlug) const
 Helper to construct the page URL for the authorised upload. More...
 
std::chrono::milliseconds GetProgressCallbackTimeout () const
 Timeout between progress callbacks. More...
 
std::vector< std::string > GetPreferredAudioFormats () const
 Preferred audio format. More...
 
rapidjson::Document GetExportConfig (const std::string &exporterName) const
 Export configuration suitable for the mime type provided. More...
 
std::string GetDownloadMime () const
 Return the mime type server should store the file. This is a requirement from audiocom. More...
 
std::string GetAcceptLanguageValue () const
 Returns the preferred language. More...
 

Detailed Description

Configuration for the audio.com.

Definition at line 23 of file ServiceConfig.h.

Member Function Documentation

◆ GetAcceptLanguageValue()

std::string cloud::audiocom::ServiceConfig::GetAcceptLanguageValue ( ) const

Returns the preferred language.

Definition at line 105 of file ServiceConfig.cpp.

106{
107 auto language = Languages::GetLang();
108
109 if (language.Contains(L"-") && language.Length() > 2)
110 return wxString::Format("%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2)).ToStdString();
111 else
112 return wxString::Format("%s;q=1.0, *;q=0.5", language).ToStdString();
113}
wxString GetLang()
Definition: Languages.cpp:395

References Languages::GetLang().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::SetRequiredHeaders().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAPIEndpoint()

std::string_view cloud::audiocom::ServiceConfig::GetAPIEndpoint ( ) const

API endpoint.

Definition at line 19 of file ServiceConfig.cpp.

20{
21 return "https://api.audio.com";
22}

Referenced by GetAPIUrl().

Here is the caller graph for this function:

◆ GetAPIUrl()

std::string cloud::audiocom::ServiceConfig::GetAPIUrl ( std::string_view  apiURI) const

Helper to construct the full URLs for the API.

Definition at line 44 of file ServiceConfig.cpp.

45{
46 return std::string(GetAPIEndpoint()) + std::string(apiURI);
47}
std::string_view GetAPIEndpoint() const
API endpoint.

References GetAPIEndpoint().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::DiscardResult(), cloud::audiocom::OAuthService::DoAuthorise(), and cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::InitiateUpload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAudioURL()

std::string cloud::audiocom::ServiceConfig::GetAudioURL ( std::string_view  userSlug,
std::string_view  audioSlug 
) const

Helper to construct the page URL for the authorised upload.

Definition at line 57 of file ServiceConfig.cpp.

59{
60 return "https://audio.com/" + std::string(userSlug) + "/audio/" + std::string(audioSlug) + "/edit";
61}

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::CompletePromise().

Here is the caller graph for this function:

◆ GetDownloadMime()

std::string cloud::audiocom::ServiceConfig::GetDownloadMime ( ) const

Return the mime type server should store the file. This is a requirement from audiocom.

Definition at line 100 of file ServiceConfig.cpp.

101{
102 return "audio/x-wav";
103}

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::GetUploadRequestPayload().

Here is the caller graph for this function:

◆ GetExportConfig()

rapidjson::Document cloud::audiocom::ServiceConfig::GetExportConfig ( const std::string &  exporterName) const

Export configuration suitable for the mime type provided.

Definition at line 73 of file ServiceConfig.cpp.

74{
75 if(mimeType == "audio/x-wavpack")
76 {
77 rapidjson::Document config;
78 config.SetObject();
79 config.AddMember("quality", rapidjson::Value(2), config.GetAllocator());
80 config.AddMember("bit_rate", rapidjson::Value(40), config.GetAllocator());
81 config.AddMember("bit_depth", 24, config.GetAllocator());
82 config.AddMember("hybrid_mode", false, config.GetAllocator());
83 return config;
84 }
85 if(mimeType == "audio/x-flac")
86 {
87 rapidjson::Document config;
88 config.SetObject();
89 config.AddMember("bit_depth", rapidjson::Value(24), config.GetAllocator());
90 config.AddMember("level", rapidjson::Value(5), config.GetAllocator());
91 }
92 if(mimeType == "audio/x-wav")
93 {
94 return {};
95 }
96 throw std::invalid_argument("unknown mime-type");
97}

Referenced by cloud::audiocom::ShareAudioDialog::ExportProject().

Here is the caller graph for this function:

◆ GetFinishUploadPage()

std::string cloud::audiocom::ServiceConfig::GetFinishUploadPage ( std::string_view  audioID,
std::string_view  token 
) const

Helper to construct the page URL for the anonymous upload last stage.

Definition at line 49 of file ServiceConfig.cpp.

51{
52 return "https://audio.com/audacity/upload?audioId=" + std::string(audioID) +
53 "&token=" + std::string(token) +
54 "&clientId=" + std::string(GetOAuthClientID());
55}
std::string_view GetOAuthClientID() const
OAuth2 client ID.

References GetOAuthClientID().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::CompletePromise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOAuthClientID()

std::string_view cloud::audiocom::ServiceConfig::GetOAuthClientID ( ) const

OAuth2 client ID.

Definition at line 33 of file ServiceConfig.cpp.

34{
35 return "1741964426607541";
36}

Referenced by GetFinishUploadPage(), GetOAuthLoginPage(), and cloud::audiocom::anonymous_namespace{OAuthService.cpp}::WriteCommonFields().

Here is the caller graph for this function:

◆ GetOAuthLoginPage()

std::string_view cloud::audiocom::ServiceConfig::GetOAuthLoginPage ( ) const

Page to open in browser to initiate OAuth.

Definition at line 24 of file ServiceConfig.cpp.

25{
26 static const std::string loginPage =
27 std::string("https://audio.com/audacity/link?clientId=") +
28 std::string(GetOAuthClientID());
29
30 return loginPage;
31}

References GetOAuthClientID().

Here is the call graph for this function:

◆ GetOAuthRedirectURL()

std::string_view cloud::audiocom::ServiceConfig::GetOAuthRedirectURL ( ) const

OAuth2 redirect URL. Only used to satisfy the protocol.

Definition at line 38 of file ServiceConfig.cpp.

39{
40 //return "audacity://link";
41 return "https://audio.com/auth/sign-in/success";
42}

Referenced by cloud::audiocom::OAuthService::AuthoriseCode().

Here is the caller graph for this function:

◆ GetPreferredAudioFormats()

std::vector< std::string > cloud::audiocom::ServiceConfig::GetPreferredAudioFormats ( ) const

Preferred audio format.

Definition at line 68 of file ServiceConfig.cpp.

69{
70 return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
71}

◆ GetProgressCallbackTimeout()

std::chrono::milliseconds cloud::audiocom::ServiceConfig::GetProgressCallbackTimeout ( ) const

Timeout between progress callbacks.

Definition at line 63 of file ServiceConfig.cpp.

64{
65 return std::chrono::seconds(3);
66}

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::HandleUploadProgress().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: