【FFmpeg】avio_open2函數

【FFmpeg】avio_open2函數

  • 1.avio_open2
    • 1.1 創建URLContext(ffurl_open_whitelist)
      • 1.1.1 創建URLContext(ffurl_alloc)
        • 1.1.1.1 查找合適的protocol(url_find_protocol)
        • 1.1.1.2 為查找到的URLProtocol創建URLContext(url_alloc_for_protocol)
      • 1.1.2 打開URLContext(ffurl_connect)
    • 1.2 根據創建的URLContext初始化AVIOContext(ffio_fdopen)
      • 1.2.1 創建AVIOContext(avio_alloc_context)
  • 2.小結

參考:
FFmpeg源代碼簡單分析:avio_open2()

示例工程:
【FFmpeg】調用ffmpeg庫實現264軟編
【FFmpeg】調用ffmpeg庫實現264軟解
【FFmpeg】調用ffmpeg庫進行RTMP推流和拉流
【FFmpeg】調用ffmpeg庫進行SDL2解碼后渲染

流程分析:
【FFmpeg】編碼鏈路上主要函數的簡單分析
【FFmpeg】解碼鏈路上主要函數的簡單分析

結構體分析:
【FFmpeg】AVCodec結構體
【FFmpeg】AVCodecContext結構體
【FFmpeg】AVStream結構體
【FFmpeg】AVFormatContext結構體
【FFmpeg】AVIOContext結構體
【FFmpeg】AVPacket結構體

函數分析:
【FFmpeg】avformat_open_input函數
【FFmpeg】avformat_find_stream_info函數
【FFmpeg】avformat_alloc_output_context2函數

avio_open2函數的內部調用關系為
在這里插入圖片描述

1.avio_open2

avio_open2函數的定義位于libavformat\avio.c中,功能是打開URL,之后方便進行讀寫操作。這里的URL是廣義的地址,對于文件而言,就是文件的路徑,如"C:\xxx\test.flv",也可以是地址例如"rtmp://127.0.0.1:1935/live/stream",flag表示控制如何打開url所指示的資源的標志,如AVIO_FLAG_READ和AVIO_FLAG_WRITE

/*** Create and initialize a AVIOContext for accessing the* resource indicated by url.* @note When the resource indicated by url has been opened in* read+write mode, the AVIOContext can be used only for writing.** @param s Used to return the pointer to the created AVIOContext.* In case of failure the pointed to value is set to NULL.* @param url resource to access* @param flags flags which control how the resource indicated by url* is to be opened* @param int_cb an interrupt callback to be used at the protocols level* @param options  A dictionary filled with protocol-private options. On return* this parameter will be destroyed and replaced with a dict containing options* that were not found. May be NULL.* @return >= 0 in case of success, a negative value corresponding to an* AVERROR code in case of failure*/
// 創建并初始化一個AVIOContext,用于訪問url指定的資源
// @note:當url所指示的資源以讀+寫方式打開時,AVIOContext只能用于寫
int avio_open2(AVIOContext **s, const char *filename, int flags,const AVIOInterruptCB *int_cb, AVDictionary **options)
{return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
}

avio_open2調用ffio_open_whitelist進行AVIOContext的創建,而ffio_open_whitelist的實現方式如下,其中主要使用了兩個函數:(1)ffurl_open_whitelist根據白名單創建URLContext;(2)ffio_fdopen根據創建的URLContext來初始化AVIOContext。其中,URLContext完成協議的讀寫操作。

int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,const AVIOInterruptCB *int_cb, AVDictionary **options,const char *whitelist, const char *blacklist)
{URLContext *h;int err;*s = NULL;// 1.根據whitelist創建URLContexterr = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);if (err < 0)return err;// 2.根據創建的URLContext初始化AVIOContexterr = ffio_fdopen(s, h);if (err < 0) {ffurl_close(h);return err;}return 0;
}

1.1 創建URLContext(ffurl_open_whitelist)

該函數的主要內容為兩個部分:(1)ffurl_alloc:創建URLContext;(2)ffurl_connect:打開已創建的URLContext;

int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,const AVIOInterruptCB *int_cb, AVDictionary **options,const char *whitelist, const char* blacklist,URLContext *parent)
{AVDictionary *tmp_opts = NULL;AVDictionaryEntry *e;// 創建URLContextint ret = ffurl_alloc(puc, filename, flags, int_cb);if (ret < 0)return ret;if (parent) {ret = av_opt_copy(*puc, parent);if (ret < 0)goto fail;}if (options &&(ret = av_opt_set_dict(*puc, options)) < 0)goto fail;if (options && (*puc)->prot->priv_data_class &&(ret = av_opt_set_dict((*puc)->priv_data, options)) < 0)goto fail;if (!options)options = &tmp_opts;av_assert0(!whitelist ||!(e=av_dict_get(*options, "protocol_whitelist", NULL, 0)) ||!strcmp(whitelist, e->value));av_assert0(!blacklist ||!(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||!strcmp(blacklist, e->value));if ((ret = av_dict_set(options, "protocol_whitelist", whitelist, 0)) < 0)goto fail;if ((ret = av_dict_set(options, "protocol_blacklist", blacklist, 0)) < 0)goto fail;if ((ret = av_opt_set_dict(*puc, options)) < 0)goto fail;// 打開獲得的URLProtocolret = ffurl_connect(*puc, options);if (!ret)return 0;
fail:ffurl_closep(puc);return ret;
}

1.1.1 創建URLContext(ffurl_alloc)

int ffurl_alloc(URLContext **puc, const char *filename, int flags,const AVIOInterruptCB *int_cb)
{const URLProtocol *p = NULL;// 根據filename查找合適的protocolp = url_find_protocol(filename);if (p)// 為protocol分配URLContextreturn url_alloc_for_protocol(puc, p, filename, flags, int_cb);*puc = NULL;return AVERROR_PROTOCOL_NOT_FOUND;
}
1.1.1.1 查找合適的protocol(url_find_protocol)

函數主要工作是調用ffurl_get_protocols獲取一個protocol

static const struct URLProtocol *url_find_protocol(const char *filename)
{const URLProtocol **protocols;char proto_str[128], proto_nested[128], *ptr;size_t proto_len = strspn(filename, URL_SCHEME_CHARS);int i;if (filename[proto_len] != ':' &&(strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||is_dos_path(filename))strcpy(proto_str, "file");elseav_strlcpy(proto_str, filename,FFMIN(proto_len + 1, sizeof(proto_str)));av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));if ((ptr = strchr(proto_nested, '+')))*ptr = '\0';// 尋找一個protocolsprotocols = ffurl_get_protocols(NULL, NULL);if (!protocols)return NULL;for (i = 0; protocols[i]; i++) {const URLProtocol *up = protocols[i];if (!strcmp(proto_str, up->name)) {av_freep(&protocols);return up;}if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&!strcmp(proto_nested, up->name)) {av_freep(&protocols);return up;}}av_freep(&protocols);if (av_strstart(filename, "https:", NULL) || av_strstart(filename, "tls:", NULL))av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile FFmpeg with ""openssl, gnutls or securetransport enabled.\n");return NULL;
}

ffurl_get_protocol的定義如下,大致的流程是遍歷可選的url_protocol,檢查是否位于白名單中且不在黑名單中

const URLProtocol **ffurl_get_protocols(const char *whitelist,const char *blacklist)
{const URLProtocol **ret;int i, ret_idx = 0;ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));if (!ret)return NULL;for (i = 0; url_protocols[i]; i++) {const URLProtocol *up = url_protocols[i];if (whitelist && *whitelist && !av_match_name(up->name, whitelist))continue;if (blacklist && *blacklist && av_match_name(up->name, blacklist))continue;ret[ret_idx++] = up;}return ret;
}
1.1.1.2 為查找到的URLProtocol創建URLContext(url_alloc_for_protocol)

在創建URLContext時,會先檢查flag和函數對應的關系:(1)網絡操作;(2)讀取;(3)寫入;如果有一個初始化失敗,則返回錯誤

static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,const char *filename, int flags,const AVIOInterruptCB *int_cb)
{URLContext *uc;int err;// flag中包含NETWORK,但是網絡初始化模塊失敗,則返回錯誤
#if CONFIG_NETWORKif (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())return AVERROR(EIO);
#endif// flag中包含AVIO_FLAG_READ,但是不包含url_read,則輸出錯誤if ((flags & AVIO_FLAG_READ) && !up->url_read) {av_log(NULL, AV_LOG_ERROR,"Impossible to open the '%s' protocol for reading\n", up->name);return AVERROR(EIO);}// flag中包含AVIO_FALG_WRITE,但是不包含url_write,則輸出錯誤if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {av_log(NULL, AV_LOG_ERROR,"Impossible to open the '%s' protocol for writing\n", up->name);return AVERROR(EIO);}// 前續檢查結束,創建結構體,并且進行初始化賦值uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);if (!uc) {err = AVERROR(ENOMEM);goto fail;}uc->av_class = &url_context_class;uc->filename = (char *)&uc[1];strcpy(uc->filename, filename);uc->prot            = up;uc->flags           = flags;uc->is_streamed     = 0; /* default = not streamed */uc->max_packet_size = 0; /* default: stream file */if (up->priv_data_size) {uc->priv_data = av_mallocz(up->priv_data_size);if (!uc->priv_data) {err = AVERROR(ENOMEM);goto fail;}if (up->priv_data_class) {char *start;*(const AVClass **)uc->priv_data = up->priv_data_class;av_opt_set_defaults(uc->priv_data);if (av_strstart(uc->filename, up->name, (const char**)&start) && *start == ',') {int ret= 0;char *p= start;char sep= *++p;char *key, *val;p++;if (strcmp(up->name, "subfile"))ret = AVERROR(EINVAL);while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){*val= *key= 0;ret = av_opt_set(uc->priv_data, p, key+1, 0);if (ret == AVERROR_OPTION_NOT_FOUND)av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);*val= *key= sep;p= val+1;}if(ret<0 || p!=key){av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);err = AVERROR(EINVAL);goto fail;}memmove(start, key+1, strlen(key));}}}if (int_cb)uc->interrupt_callback = *int_cb;*puc = uc;return 0;
fail:*puc = NULL;if (uc)av_freep(&uc->priv_data);av_freep(&uc);
#if CONFIG_NETWORKif (up->flags & URL_PROTOCOL_FLAG_NETWORK)ff_network_close();
#endifreturn err;
}

1.1.2 打開URLContext(ffurl_connect)

函數的主要功能是打開前面創建的URLContext,首先檢查前面創建的URLContext是否被正確初始化,然后調用url_open打開URL

int ffurl_connect(URLContext *uc, AVDictionary **options)
{int err;AVDictionary *tmp_opts = NULL;AVDictionaryEntry *e;if (!options)options = &tmp_opts;// Check that URLContext was initialized correctly and lists are matching if set// 檢查URLContext被正確的初始化// 如果設置了黑白名單需要檢查URLContext是否符合要求av_assert0(!(e=av_dict_get(*options, "protocol_whitelist", NULL, 0)) ||(uc->protocol_whitelist && !strcmp(uc->protocol_whitelist, e->value)));av_assert0(!(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||(uc->protocol_blacklist && !strcmp(uc->protocol_blacklist, e->value)));if (uc->protocol_whitelist && av_match_list(uc->prot->name, uc->protocol_whitelist, ',') <= 0) {av_log(uc, AV_LOG_ERROR, "Protocol '%s' not on whitelist '%s'!\n", uc->prot->name, uc->protocol_whitelist);return AVERROR(EINVAL);}if (uc->protocol_blacklist && av_match_list(uc->prot->name, uc->protocol_blacklist, ',') > 0) {av_log(uc, AV_LOG_ERROR, "Protocol '%s' on blacklist '%s'!\n", uc->prot->name, uc->protocol_blacklist);return AVERROR(EINVAL);}if (!uc->protocol_whitelist && uc->prot->default_whitelist) {av_log(uc, AV_LOG_DEBUG, "Setting default whitelist '%s'\n", uc->prot->default_whitelist);uc->protocol_whitelist = av_strdup(uc->prot->default_whitelist);if (!uc->protocol_whitelist) {return AVERROR(ENOMEM);}} else if (!uc->protocol_whitelist)av_log(uc, AV_LOG_DEBUG, "No default whitelist set\n"); // This should be an error once all declare a default whitelistif ((err = av_dict_set(options, "protocol_whitelist", uc->protocol_whitelist, 0)) < 0)return err;if ((err = av_dict_set(options, "protocol_blacklist", uc->protocol_blacklist, 0)) < 0)return err;// 使用url_open2或者url_open// 對于協議例如file,ftp,rtp,tcp,libRTMP等,使用的是url_open// 對于http協議,使用的是url_open2// 如果是file,url_open會鏈接到ftp_open()// 如果是libRTMP,url_open會鏈接到rtmp_open()err =uc->prot->url_open2 ? uc->prot->url_open2(uc,uc->filename,uc->flags,options) :uc->prot->url_open(uc, uc->filename, uc->flags);av_dict_set(options, "protocol_whitelist", NULL, 0);av_dict_set(options, "protocol_blacklist", NULL, 0);if (err)return err;uc->is_connected = 1;/* We must be careful here as ffurl_seek() could be slow,* for example for http */if ((uc->flags & AVIO_FLAG_WRITE) || !strcmp(uc->prot->name, "file"))if (!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)uc->is_streamed = 1;return 0;
}

例如協議的格式為ftp,會調用ftp_open,定義如下;會調用ftp_connect實現ftp連接的打開

static int ftp_open(URLContext *h, const char *url, int flags)
{FTPContext *s = h->priv_data;int err;ff_dlog(h, "ftp protocol open\n");if ((err = ftp_connect(h, url)) < 0)goto fail;if (ftp_restart(s, 0) < 0) {h->is_streamed = 1;} else {ftp_file_size(s);if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)h->is_streamed = 1;}return 0;fail:av_log(h, AV_LOG_ERROR, "FTP open failed\n");ftp_close(h);return err;
}

1.2 根據創建的URLContext初始化AVIOContext(ffio_fdopen)

/*** Create and initialize a AVIOContext for accessing the* resource referenced by the URLContext h.* @note When the URLContext h has been opened in read+write mode, the* AVIOContext can be used only for writing.** @param s Used to return the pointer to the created AVIOContext.* In case of failure the pointed to value is set to NULL.* @return >= 0 in case of success, a negative value corresponding to an* AVERROR code in case of failure*/
// 創建并初始化一個AVIOContext,用于訪問URLContext引用的資源
// @note 如果URLContext已經以read + write模式打開,那么AVIOContext只能被用于writing
int ffio_fdopen(AVIOContext **sp, URLContext *h)
{AVIOContext *s;uint8_t *buffer = NULL;int buffer_size, max_packet_size;// 首先初始化AVIOContext當中的buffer,如果前面配置max_packet_size,則將其配置為buffer_size// 否則將buffer_size配置為IO_BUFFER_SIZE=32768max_packet_size = h->max_packet_size;if (max_packet_size) {// buffer_size不必超過packet最大size,因為最多填充一個packet即可buffer_size = max_packet_size; /* no need to bufferize more than one packet */} else {buffer_size = IO_BUFFER_SIZE;}if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {if (buffer_size > INT_MAX/2)return AVERROR(EINVAL);buffer_size *= 2;}buffer = av_malloc(buffer_size);if (!buffer)return AVERROR(ENOMEM);// 創建AVIOContext*sp = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,ffurl_read2, ffurl_write2, ffurl_seek2);if (!*sp) {av_freep(&buffer);return AVERROR(ENOMEM);}s = *sp;if (h->protocol_whitelist) {s->protocol_whitelist = av_strdup(h->protocol_whitelist);if (!s->protocol_whitelist) {avio_closep(sp);return AVERROR(ENOMEM);}}if (h->protocol_blacklist) {s->protocol_blacklist = av_strdup(h->protocol_blacklist);if (!s->protocol_blacklist) {avio_closep(sp);return AVERROR(ENOMEM);}}s->direct = h->flags & AVIO_FLAG_DIRECT;s->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;s->max_packet_size = max_packet_size;s->min_packet_size = h->min_packet_size;if(h->prot) {s->read_pause = h->prot->url_read_pause;s->read_seek  = h->prot->url_read_seek;if (h->prot->url_read_seek)s->seekable |= AVIO_SEEKABLE_TIME;}((FFIOContext*)s)->short_seek_get = ffurl_get_short_seek;s->av_class = &ff_avio_class;return 0;
}

1.2.1 創建AVIOContext(avio_alloc_context)

該函數首先使用av_malloc創建FFIOContext,隨后通過調用ffio_init_context來初始化,這里做了一個封裝,先通過初始化FFIOContext,隨后返回FFIOContext之中的AVIOContext

AVIOContext *avio_alloc_context(unsigned char *buffer,int buffer_size,int write_flag,void *opaque,int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),int64_t (*seek)(void *opaque, int64_t offset, int whence))
{FFIOContext *s = av_malloc(sizeof(*s));if (!s)return NULL;ffio_init_context(s, buffer, buffer_size, write_flag, opaque,read_packet, write_packet, seek);return &s->pub;
}

ffio_init_context的初始化操作為

void ffio_init_context(FFIOContext *ctx,unsigned char *buffer,int buffer_size,int write_flag,void *opaque,int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),int64_t (*seek)(void *opaque, int64_t offset, int whence))
{AVIOContext *const s = &ctx->pub;memset(ctx, 0, sizeof(*ctx));s->buffer      = buffer;ctx->orig_buffer_size =s->buffer_size = buffer_size;s->buf_ptr     = buffer;s->buf_ptr_max = buffer;s->opaque      = opaque;s->direct      = 0;url_resetbuf(s, write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);s->write_packet    = write_packet;s->read_packet     = read_packet;s->seek            = seek;s->pos             = 0;s->eof_reached     = 0;s->error           = 0;s->seekable        = seek ? AVIO_SEEKABLE_NORMAL : 0;s->min_packet_size = 0;s->max_packet_size = 0;s->update_checksum = NULL;ctx->short_seek_threshold = SHORT_SEEK_THRESHOLD;if (!read_packet && !write_flag) {s->pos     = buffer_size;s->buf_end = s->buffer + buffer_size;}s->read_pause = NULL;s->read_seek  = NULL;s->write_data_type       = NULL;s->ignore_boundary_point = 0;ctx->current_type        = AVIO_DATA_MARKER_UNKNOWN;ctx->last_time           = AV_NOPTS_VALUE;ctx->short_seek_get      = NULL;
}

2.小結

avio_open2函數用于為指定的URL創建一個URLContext,并且打開它,隨后基于這個URLContext創建一個AVIOContext,從而實現對數據源的控制。在AVIOContext中,可以使用read_packet和write_packet進行packet讀寫操作,在URLProtocol中,可以使用url_read和url_write從protocol中讀寫數據。

因為還不是很理解協議層procotol的內容,下面是從別的地方看來的對于read_packet和url_read的理解
url_read和read_packet都是用于讀取數據的函數,但實現方式和應用場景有所不同:
(1)url_read
主要用于從網絡URL中讀取數據。在實際應用中,可能會涉及到更復雜的網絡協議,如http和rtmp。例如librtmp庫中的RTMP packet結構就復雜處理發送和接收過程中的協議解析、分包、合包等復雜邏輯
(2)read_packet
主要用于從數據流當中讀取特定格式的數據包。在FFmpeg中,av_read_frame()函數就是用來讀取AVPacket的。這種情況下,數據處理可能會涉及更加復雜的數據流處理,如解碼、過濾等

CSDN : https://blog.csdn.net/weixin_42877471
Github : https://github.com/DoFulangChen

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/37318.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/37318.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/37318.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

影響Cache命中率的因素有哪些?

緩存命中率&#xff08;Cache Hit Rate&#xff09;是指處理器訪問緩存時&#xff0c;所需數據已經在緩存中找到的次數與總訪問次數的比例。提高緩存命中率可以顯著提升系統性能&#xff0c;因為緩存訪問速度遠快于主存訪問速度。影響緩存命中率的關鍵因素包括&#xff1a; 1.…

C語言異常處理就機制setjmp()和longjmp()

C語言setjmp()和longjmp()實現異常處理機制。 setjmp() 用于保存當前的程序執行狀態。 longjmp() 用于在后面的某個時刻返回到setjmp()點的狀態。 類似goto。但goto是本地的&#xff0c;只能在函數內部跳轉。 setjmp()和longjmp()是非局部跳轉語句&#xff0c;可在調用棧上&a…

通信系統網絡架構_3.移動通信網絡架構

移動通信網為移動互聯網提供了強有力的支持&#xff0c;尤其是5G網絡為個人用戶、垂直行業等提供了多樣化的服務。以下從業務應用角度給出面向5G網絡的組網方式。 1.5GS與DN互連 5GS&#xff08;5G System&#xff09;在為移動終端用戶&#xff08;User Equipment&#xff0c;…

CSRF的其他防范措施?

一般情況下&#xff0c;我們可以通過各種防護策略來防御CSRF&#xff0c;對于QA、SRE、安全負責人等&#xff0c;我們可以做哪些事情來提升安全性呢&#xff1f; 一、CSRF測試 CSRFTester是一款CSRF漏洞的測試工具&#xff0c;CSRFTester工具的測試原理大概是這樣的&#xff…

BLACKBOX.AI:解鎖開發新紀元,加速編程學習的AI神器!

文章目錄 &#x1f4af;BLACKBOX.AI 官網&#x1f341;1 BLACKBOX.AI 工具使用教程&#x1f341;2 BLACKBOX.AI工具使用界面介紹&#x1f341;3 Chat(聊天)功能&#x1f341;4 Explore (探索)功能&#x1f48e;4.1 Terminal(終端)功能&#x1f48e;4.2 Discover(發現)功能&…

STM32 IWDG(獨立看門狗)

1 IWDG簡介 STM32有兩個看門狗&#xff1a;一個是獨立看門狗&#xff08;IWDG&#xff09;&#xff0c;另外一個是窗口看門狗。獨立看門狗也稱寵物狗&#xff0c;窗口看門狗也稱警犬。本文主要分析獨立看門狗的功能和它的應用。 獨立看門狗用通俗一點的話來解釋就是一個12位的…

關于轉BigDecimal對象時,精度問題

//浮點型數值Double d 0.0003d;//轉BigDecimal對象BigDecimal a new BigDecimal(d);System.out.println(String.format("浮點類型數字:%.4f創建BigDecimal對象并且保留多位小數并且保留多位小數時,精度會變多,結果為%s",d,a.setScale(8, BigDecimal.ROUND_DOWN)));…

format()方法——格式化字符串

自學python如何成為大佬(目錄):https://blog.csdn.net/weixin_67859959/article/details/139049996?spm1001.2014.3001.5501 語法介紹 format()可以對數據進行格式化處理操作&#xff0c;語法如下&#xff1a; format(value, format_spec) format_spec為格式化解釋。當參數…

【計算機畢業設計】092基于微信小程序二手閑置交易市場

&#x1f64a;作者簡介&#xff1a;擁有多年開發工作經驗&#xff0c;分享技術代碼幫助學生學習&#xff0c;獨立完成自己的項目或者畢業設計。 代碼可以私聊博主獲取。&#x1f339;贈送計算機畢業設計600個選題excel文件&#xff0c;幫助大學選題。贈送開題報告模板&#xff…

PostgreSQL的系統視圖pg_stat_archiver

PostgreSQL的系統視圖pg_stat_archiver 在 PostgreSQL 數據庫中&#xff0c;pg_stat_archiver 視圖提供了關于歸檔進程&#xff08;archiver process&#xff09;的統計信息。歸檔進程負責將 WAL&#xff08;Write-Ahead Logging&#xff09;日志文件復制到歸檔存儲&#xff0…

探索區塊鏈:顛覆性技術的崛起

目錄 一、引言 二、區塊鏈技術概述 三、區塊鏈應用場景 四、區塊鏈面臨的挑戰 五、區塊鏈的未來展望 六、結語 一、引言 在數字化浪潮的推動下&#xff0c;區塊鏈技術以其獨特的去中心化、透明性和不可篡改性等特性&#xff0c;正在逐步改變我們的生活。從金融領域到供應…

基于Java的茶文化交流系統【附源碼+LW】

摘 要 計算機網絡發展到現在已經好幾十年了&#xff0c;在理論上面已經有了很豐富的基礎&#xff0c;并且在現實生活中也到處都在使用&#xff0c;可以說&#xff0c;經過幾十年的發展&#xff0c;互聯網技術已經把地域信息的隔閡給消除了&#xff0c;讓整個世界都可以即時通話…

MySQL數據庫存儲引擎

MySQL數據庫存儲引擎 存儲引擎概念 存儲引擎也稱為表類型 通過不同的技術比如說&#xff0c;存儲機制&#xff0c;索引技巧&#xff0c;鎖定水平等等&#xff0c;來提供不同的功能。 查看MySQL支持的存儲引擎 show engines\G&#xff1b; 常用引擎比較 對事務有需求 innodb …

TiDB-從0到1-數據導出導入

TiDB從0到1系列 TiDB-從0到1-體系結構TiDB-從0到1-分布式存儲TiDB-從0到1-分布式事務TiDB-從0到1-MVCCTiDB-從0到1-部署篇TiDB-從0到1-配置篇TiDB-從0到1-集群擴縮容 一、數據導出 TiDB中通過Dumpling來實現數據導出&#xff0c;與MySQL中的mysqldump類似&#xff0c;其屬于…

Spring Boot中如何配置和使用多數據源

Spring Boot中如何配置和使用多數據源 大家好&#xff0c;我是免費搭建查券返利機器人省錢賺傭金就用微賺淘客系統3.0的小編&#xff0c;也是冬天不穿秋褲&#xff0c;天冷也要風度的程序猿&#xff01;今天&#xff0c;我們將深入探討如何在Spring Boot應用中配置和使用多數據…

oracle with as 是什么并且怎么用

Oracle中的WITH AS語句&#xff0c;也被稱為Common Table Expressions&#xff08;CTE&#xff09;&#xff0c;是一個用于定義臨時結果集或視圖的子句。這個臨時結果集或視圖只在當前的查詢中存在&#xff0c;并且在查詢完成后會被自動刪除。使用WITH AS可以提高SQL語句的可讀…

JavaWeb——MySQL:navicate客戶端工具簡單使用

目錄 1. 連接 2. 新建數據庫 3. 使用數據庫 4. 新建表 5.使用表 6. 導出數據庫 我這里是英文版&#xff0c;沒有進行漢化。 1. 連接 點擊左上角Connection&#xff0c;選擇MySQL&#xff0c;&#xff08;我連接的是自己計算機上的數據庫&#xff09;連接名輸入&#x…

使用ScheduledExecutorService進行任務調度

使用ScheduledExecutorService進行任務調度 大家好&#xff0c;我是免費搭建查券返利機器人省錢賺傭金就用微賺淘客系統3.0的小編&#xff0c;也是冬天不穿秋褲&#xff0c;天冷也要風度的程序猿&#xff01; 在軟件開發中&#xff0c;任務調度是一項重要的技術需求&#xff…

抖音開放平臺運營同學聯系我了,非常感謝

大家好&#xff0c;我是小悟 是怎么個事呢&#xff1f; 前幾天在對接抖音開放平臺&#xff0c;服務商代開發小程序里面的小程序備案&#xff0c;上傳備案圖片接口遇到了問題&#xff0c;具體的問題可詳閱【抖音開放平臺&#xff0c;這誰寫的&#xff0c;要扣績效吧】。 評論…

Zoom視頻會議的虛擬背景功能:打造個性化會議體驗

在遠程工作和在線交流日益普及的今天&#xff0c;視頻會議已成為連接人們的橋梁。Zoom視頻會議軟件因其出色的音視頻質量和豐富的功能而廣受歡迎。其中&#xff0c;虛擬背景功能是Zoom的一大亮點&#xff0c;它不僅能夠保護用戶隱私&#xff0c;還能為會議增添趣味性。本文將詳…