diff options
| author | Mistivia <i@mistivia.com> | 2025-09-14 15:58:34 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-09-14 15:58:34 +0800 |
| commit | c5c3ec74e8f39995a060e105e95db1d8d8908180 (patch) | |
| tree | 4ce4d7fc15906012d97e06a725ed5d537328de5c | |
| parent | 1c53bb350cfa2ec6941a5f24571f54c0ee5ce387 (diff) | |
delete unused config
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | ezlive_config.c | 7 | ||||
| -rw-r--r-- | ezlive_config.h | 1 | ||||
| -rw-r--r-- | s3_client.cpp | 18 | ||||
| -rw-r--r-- | transcode_talker.c | 12 |
5 files changed, 23 insertions, 18 deletions
@@ -3,4 +3,5 @@ ezlive *.flv *.ts *.m3u8 -a.out
\ No newline at end of file +a.out +config
\ No newline at end of file diff --git a/ezlive_config.c b/ezlive_config.c index 08347d8..a8fa258 100644 --- a/ezlive_config.c +++ b/ezlive_config.c @@ -23,10 +23,9 @@ void EZLiveConfig_init(EZLiveConfig *self) { self->listening_port = 1935; self->bucket = NULL; self->endpoint = NULL; - self->s3_path = NULL; + self->s3_path = strdup("ezlive/"); self->access_key = NULL; self->secret_key = NULL; - self->web_endpoint = NULL; self->region = strdup("auto"); } @@ -76,8 +75,6 @@ void EZLiveConfig_load(EZLiveConfig *self, const char *filename) { set_field(&self->access_key, val); } else if (strcmp(key, "secret_key") == 0) { set_field(&self->secret_key, val); - } else if (strcmp(key, "web_endpoint") == 0) { - set_field(&self->web_endpoint, val); } else if (strcmp(key, "region") == 0) { set_field(&self->region, val); } @@ -91,7 +88,7 @@ int EZLiveConfig_validate(EZLiveConfig *self) { if (!self->listening_addr || strlen(self->listening_addr) == 0) return -2; if (!self->bucket || strlen(self->bucket) == 0) return -3; if (!self->endpoint || strlen(self->endpoint) == 0) return -4; - if (!self->s3_path || strlen(self->s3_path) == 0) return -5; + if (!self->s3_path || strlen(self->s3_path) < 2) return -5; if (self->s3_path[strlen(self->s3_path) - 1] != '/') { fprintf(stderr, "invalid s3 path. path should end with '\'.\n"); return -10; diff --git a/ezlive_config.h b/ezlive_config.h index 58b3f7d..a8ba0b7 100644 --- a/ezlive_config.h +++ b/ezlive_config.h @@ -9,7 +9,6 @@ typedef struct { const char *s3_path; const char *access_key; const char *secret_key; - const char *web_endpoint; const char *region; } EZLiveConfig; diff --git a/s3_client.cpp b/s3_client.cpp index 42aa05c..4076b1c 100644 --- a/s3_client.cpp +++ b/s3_client.cpp @@ -1,5 +1,6 @@ #include "s3_client.h" +#include <stdio.h> #include <fstream> #include <iostream> @@ -34,15 +35,12 @@ void S3Client_put(const char *filename, const char *object_name) { while (1) { Aws::S3::Model::PutObjectRequest request; request.SetBucket(ezlive_config->bucket); - //We are using the name of the file as the key for the object in the bucket. - //However, this is just a string and can be set according to your retrieval needs. request.SetKey(object_name); - std::shared_ptr<Aws::IOStream> inputData = std::make_shared<Aws::FStream>(filename, std::ios_base::in | std::ios_base::binary); if (!*inputData) { - std::cerr << "Error unable to read file " << filename << std::endl; + fprintf(stderr, "Error unable to read file: %s\n", filename); return; } @@ -52,13 +50,11 @@ void S3Client_put(const char *filename, const char *object_name) { s3client->PutObject(request); if (!outcome.IsSuccess()) { - std::cerr << "Error: putObject: " << - outcome.GetError().GetMessage() << std::endl; + fprintf(stderr, "Error: putObject: %s.\n", outcome.GetError().GetMessage().c_str()); sleep(3); continue; } else { - std::cout << "Added object '" << object_name << "' to bucket '" - << ezlive_config->bucket << "'."; + printf("Added object '%s' to bucket '%s'.\n", object_name, ezlive_config->bucket); break; } } @@ -75,9 +71,9 @@ void S3Client_delete(const char *object_name) { if (!outcome.IsSuccess()) { auto err = outcome.GetError(); - std::cerr << "Error: deleteObject: " << - err.GetExceptionName() << ": " << err.GetMessage() << std::endl; + fprintf(stderr, "Error: deleteObject: %s: %s\n", + err.GetExceptionName().c_str(), err.GetMessage().c_str()); } else { - std::cout << "Successfully deleted the object: " << object_name << std::endl; + fprintf(stdout, "Successfully deleted the object: %s\n", object_name); } }
\ No newline at end of file diff --git a/transcode_talker.c b/transcode_talker.c index 5dd9715..3e2f05c 100644 --- a/transcode_talker.c +++ b/transcode_talker.c @@ -126,6 +126,10 @@ static void update_m3u8(HlsList *lst, int last_seg) { char out_filename[256]; tmp_local_filename("/tmp/ezlive", out_filename); FILE *fp = fopen(out_filename, "w"); + if (fp == NULL) { + fprintf(stderr, "failed to open %s for output.\n", out_filename); + exit(-1); + } if (lst->len == 0) { fprintf(fp, "\n"); } else { @@ -247,6 +251,14 @@ void* TranscodeTalker_main (void *vself) { segment_start_pts = pts_time; tmp_local_filename("/tmp/ezlive", out_filename); output_stream = start_new_output_file(in_fmt_ctx, &out_fmt_ctx, out_filename, audio_stream_index, video_stream_index); + if (pkt.stream_index == video_stream_index) + out_stream = output_stream.video_stream; + else if (pkt.stream_index == audio_stream_index) + out_stream = output_stream.audio_stream; + else { + av_packet_unref(&pkt); + continue; + } } } pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); |
