| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/FixedArray.h>
 | 
					
						
							|  |  |  | #include <AK/Function.h>
 | 
					
						
							|  |  |  | #include <AK/NonnullOwnPtr.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-20 12:43:04 -04:00
										 |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | #include <LibAudio/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Platform { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AudioCodecPlugin { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-06-20 12:43:04 -04:00
										 |  |  |     using AudioCodecPluginCreator = Function<ErrorOr<NonnullOwnPtr<AudioCodecPlugin>>(NonnullRefPtr<Audio::Loader>)>; | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 12:43:04 -04:00
										 |  |  |     static void install_creation_hook(AudioCodecPluginCreator); | 
					
						
							|  |  |  |     static ErrorOr<NonnullOwnPtr<AudioCodecPlugin>> create(NonnullRefPtr<Audio::Loader>); | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 12:43:04 -04:00
										 |  |  |     virtual ~AudioCodecPlugin(); | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-24 13:42:06 +02:00
										 |  |  |     static ErrorOr<FixedArray<Audio::Sample>> read_samples_from_loader(Audio::Loader&, size_t samples_to_load); | 
					
						
							|  |  |  |     static Duration set_loader_position(Audio::Loader&, double position, Duration duration); | 
					
						
							|  |  |  |     static Duration current_loader_position(Audio::Loader const&); | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void resume_playback() = 0; | 
					
						
							|  |  |  |     virtual void pause_playback() = 0; | 
					
						
							| 
									
										
										
										
											2023-06-14 12:59:22 -04:00
										 |  |  |     virtual void set_volume(double) = 0; | 
					
						
							| 
									
										
										
										
											2023-06-20 12:43:04 -04:00
										 |  |  |     virtual void seek(double) = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual Duration duration() = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Function<void(Duration)> on_playback_position_updated; | 
					
						
							| 
									
										
										
										
											2023-06-14 12:59:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 13:44:10 -04:00
										 |  |  | protected: | 
					
						
							|  |  |  |     AudioCodecPlugin(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |