video_player.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include <cli/cli.h>
  3. #include <dialogs/dialogs.h>
  4. #include <furi.h>
  5. #include <gui/gui.h>
  6. #include <input/input.h>
  7. #include <notification/notification_messages.h>
  8. #include <stdio.h>
  9. #include <storage/storage.h>
  10. #include <toolbox/stream/file_stream.h>
  11. #include <gui/view_dispatcher.h>
  12. #define APPSDATA_FOLDER "/ext/apps_data"
  13. #define VIDEO_PLAYER_FOLDER "/ext/apps_data/video_player"
  14. //#define VIDEO_PLAYER_FOLDER STORAGE_APP_DATA_PATH_PREFIX
  15. #define FILE_NAME_LEN 64
  16. typedef enum {
  17. EventTypeInput,
  18. EventType1stHalf,
  19. EventType2ndHalf,
  20. EventTypeJustRedraw,
  21. } EventType;
  22. typedef struct {
  23. EventType type;
  24. InputEvent input;
  25. } VideoPlayerEvent;
  26. typedef enum {
  27. VIEW_PLAYER,
  28. } VideoPlayerViews;
  29. typedef struct {
  30. View* view;
  31. void* context;
  32. } PlayerView;
  33. typedef struct {
  34. NotificationApp* notification;
  35. FuriMessageQueue* event_queue;
  36. Gui* gui;
  37. PlayerView* player_view;
  38. ViewDispatcher* view_dispatcher;
  39. Storage* storage;
  40. Stream* stream;
  41. FuriString* filepath;
  42. DialogsApp* dialogs;
  43. FuriPubSub* input;
  44. FuriPubSubSubscription* input_subscription;
  45. Canvas* canvas;
  46. uint8_t* audio_buffer;
  47. uint8_t* image_buffer;
  48. uint8_t* fake_audio_buffer; //actually not connected to any sound routine
  49. uint8_t* buffer;
  50. uint32_t num_frames;
  51. uint16_t audio_chunk_size;
  52. uint16_t sample_rate;
  53. uint8_t height;
  54. uint8_t width;
  55. uint8_t version;
  56. uint8_t x_offset;
  57. uint16_t image_buffer_length;
  58. uint32_t frames_played;
  59. int32_t frame_size;
  60. int32_t header_size; //for seeking
  61. int32_t frames_per_turn; //frames / 126, how many frames to wind forwards/backwards when seeking
  62. uint8_t progress;
  63. bool playing;
  64. bool quit;
  65. bool seeking; //to display progress bar
  66. bool silent;
  67. } VideoPlayerApp;
  68. typedef struct {
  69. VideoPlayerApp* player;
  70. } PlayerViewModel;
  71. void draw_callback(Canvas* canvas, void* ctx);
  72. bool input_callback(InputEvent* input_event, void* ctx);