anchor.diff:      end.
   
   
  --spec update_min_se(nksip:response(), nksip_call:call()) ->
  -    {ok, integer(), nksip_call:call()} | error.
  -
  -update_min_se(Resp, Call) ->
  -    case nksip_sipmsg:header(Resp, <<"Min-SE">>, integers) of
  -        [RespMinSE] ->
  -            #sipmsg{dialog_id=DialogId} = Resp,
  -            #call{opts=#call_opts{app_opts=AppOpts}, meta=CallMeta} = Call,
  -            ConfigMinSE = nksip_config:get_cached(min_session_expires, AppOpts),
  -            CurrentMinSE = case find(DialogId, Call) of
  -                #dialog{meta=DlgMeta} = Dialog ->
  -                    case nksip_lib:get_value({core, min_se}, DlgMeta) of
  -                        undefined ->
  -                            case nksip_lib:get_value({core, min_se}, CallMeta) of
  -                                undefined -> ConfigMinSE;
  -                                CallMinSE -> CallMinSE
  -                            end;
  -                        DlgMinSE ->
  -                            DlgMinSE
  -                    end;
  -                not_found ->
  -                    Dialog = undefined,
  -                    case nksip_lib:get_value({core, min_se}, CallMeta) of
  -                        undefined -> ConfigMinSE;
  -                        CallMinSE -> CallMinSE
  -                    end
  -            end,
  -            NewMinSE = max(CurrentMinSE, RespMinSE),
  -            Call1 = case Dialog of
  -                undefined ->
  -                    CallMeta1 = nksip_lib:store_value({core, min_se}, NewMinSE, CallMeta),
  -                    Call#call{meta=CallMeta1};
  -                #dialog{meta=DlgMeta1} ->
  -                    DlgMeta2 = nksip_lib:store_value({core, min_se}, NewMinSE, DlgMeta1),
  -                    Dialog2 = Dialog#dialog{meta=DlgMeta2},
  -                    store(Dialog2, Call)
  -            end,
  -            {ok, NewMinSE, Call1};
  -        _ ->
  -            error
  +%% @private Gets a value from dialog's meta, or call's meta if no dialog found
  +-spec get_meta(term(), nksip:dialog_id(), nksip_call:call()) ->
  +    term() | undefined.
  +
  +get_meta(Key, DialogId, Call) ->
  +    case find(DialogId, Call) of
  +        #dialog{meta=DlgMeta} -> nksip_lib:get_value(Key, DlgMeta);
  +        not_found -> nksip_lib:get_value(Key, Call#call.meta)
       end.
   
   
  +%% @private Stores a value in dialog's meta, or call's meta if no dialog found
  +-spec update_meta(term(), term(), nksip:dialog_id(), nksip_call:call()) ->
  +    nksip_call:call().
  +
  +update_meta(Key, Value, DialogId, Call) ->
  +    case find(DialogId, Call) of
  +        #dialog{meta=DialogMeta1} = Dialog1 ->
  +            DialogMeta2 = nksip_lib:store_value(Key, Value, DialogMeta1),
  +            Dialog2 = Dialog1#dialog{meta=DialogMeta2},
  +            store(Dialog2, Call);
  +        not_found ->
  +            #call{meta=CallMeta1} = Call,
  +            CallMeta2 = nksip_lib:store_value(Key, Value, CallMeta1),
  +            Call#call{meta=CallMeta2}
  +    end.
   
   
   %% @private Called when a dialog timer is fired
  
positive.code:     Dialog.
  
  
  %% @private
  -spec timer_update(nksip:request(), nksip:response(), 
                               nksip:dialog(), nksip_call:call()) ->
  
negative.code: -include("nksip.hrl").
  -include("nksip_call.hrl").
  
  -export([create/4, update/3, stop/3, find/2, store/2, get_meta/3, update_meta/4]).
  -export([timer/3, cast/4]).
  -export_type([sdp_offer/0]).
  
  