Q:

What happened if there is "record = State" in handle_call function?

The handle_call function in gen_server is :
Module:handle_call(Request, From, State) -> Result

But I meet one handle_call function like this：
handle_call(info, _From, #yuv{decoder = undefined} = State) ->
  {reply, [], State};

handle_call(info, _From, #yuv{decoder = Decoder} = State) ->
  {reply, av_decoder:info(Decoder), State};

handle_call(_Request, _From, State) ->
  {noreply, ok, State}.

I want to know what happened ? It's above my head
BTW: The yuv record is :
-record(yuv, {
  host,
  name,
  media,
  decoder,
  consumer
}).

A:

If I understand your question correctly, you do not understand what the following pattern does:
foo(#bar{buz = Value} = Record) -> ...

This is a common way to pattern match against whole and part of a function argument. In my example the variable Value will hold the value of the field buz and the variable Record will hold the value of the whole record. This can be applied in other cases, like:
foo([Head|Tail] = List) -> ...
foo({First, Second} = Tuple) -> ...

and so on. Instead of variables you can use literals and then the pattern matching will succeed only if the same literal appears in the call.
In your example:
handle_call(info, _From, #yuv{decoder = undefined} = State) ->
  {reply, [], State};

handle_call(info, _From, #yuv{decoder = Decoder} = State) ->
  {reply, av_decoder:info(Decoder), State};

handle_call(_Request, _From, State) ->
  {noreply, ok, State}.

The first pattern matches if the decoder field's value is undefined and then the reply is []. The second matches all the other cases for decoder and replies with the value returned by the function. In both cases State is not modified and is passed "as is" back to the internal gen_server handlers.

